{-# 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.BatchAssociateResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Associate resources to a Firewall Manager resource set.
module Amazonka.FMS.BatchAssociateResource
  ( -- * Creating a Request
    BatchAssociateResource (..),
    newBatchAssociateResource,

    -- * Request Lenses
    batchAssociateResource_resourceSetIdentifier,
    batchAssociateResource_items,

    -- * Destructuring the Response
    BatchAssociateResourceResponse (..),
    newBatchAssociateResourceResponse,

    -- * Response Lenses
    batchAssociateResourceResponse_httpStatus,
    batchAssociateResourceResponse_resourceSetIdentifier,
    batchAssociateResourceResponse_failedItems,
  )
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:/ 'newBatchAssociateResource' smart constructor.
data BatchAssociateResource = BatchAssociateResource'
  { -- | A unique identifier for the resource set, used in a TODO to refer to the
    -- resource set.
    BatchAssociateResource -> Text
resourceSetIdentifier :: Prelude.Text,
    -- | The uniform resource identifiers (URIs) of resources that should be
    -- associated to the resource set. The URIs must be Amazon Resource Names
    -- (ARNs).
    BatchAssociateResource -> [Text]
items :: [Prelude.Text]
  }
  deriving (BatchAssociateResource -> BatchAssociateResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchAssociateResource -> BatchAssociateResource -> Bool
$c/= :: BatchAssociateResource -> BatchAssociateResource -> Bool
== :: BatchAssociateResource -> BatchAssociateResource -> Bool
$c== :: BatchAssociateResource -> BatchAssociateResource -> Bool
Prelude.Eq, ReadPrec [BatchAssociateResource]
ReadPrec BatchAssociateResource
Int -> ReadS BatchAssociateResource
ReadS [BatchAssociateResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchAssociateResource]
$creadListPrec :: ReadPrec [BatchAssociateResource]
readPrec :: ReadPrec BatchAssociateResource
$creadPrec :: ReadPrec BatchAssociateResource
readList :: ReadS [BatchAssociateResource]
$creadList :: ReadS [BatchAssociateResource]
readsPrec :: Int -> ReadS BatchAssociateResource
$creadsPrec :: Int -> ReadS BatchAssociateResource
Prelude.Read, Int -> BatchAssociateResource -> ShowS
[BatchAssociateResource] -> ShowS
BatchAssociateResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchAssociateResource] -> ShowS
$cshowList :: [BatchAssociateResource] -> ShowS
show :: BatchAssociateResource -> String
$cshow :: BatchAssociateResource -> String
showsPrec :: Int -> BatchAssociateResource -> ShowS
$cshowsPrec :: Int -> BatchAssociateResource -> ShowS
Prelude.Show, forall x. Rep BatchAssociateResource x -> BatchAssociateResource
forall x. BatchAssociateResource -> Rep BatchAssociateResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchAssociateResource x -> BatchAssociateResource
$cfrom :: forall x. BatchAssociateResource -> Rep BatchAssociateResource x
Prelude.Generic)

-- |
-- Create a value of 'BatchAssociateResource' 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:
--
-- 'resourceSetIdentifier', 'batchAssociateResource_resourceSetIdentifier' - A unique identifier for the resource set, used in a TODO to refer to the
-- resource set.
--
-- 'items', 'batchAssociateResource_items' - The uniform resource identifiers (URIs) of resources that should be
-- associated to the resource set. The URIs must be Amazon Resource Names
-- (ARNs).
newBatchAssociateResource ::
  -- | 'resourceSetIdentifier'
  Prelude.Text ->
  BatchAssociateResource
newBatchAssociateResource :: Text -> BatchAssociateResource
newBatchAssociateResource Text
pResourceSetIdentifier_ =
  BatchAssociateResource'
    { $sel:resourceSetIdentifier:BatchAssociateResource' :: Text
resourceSetIdentifier =
        Text
pResourceSetIdentifier_,
      $sel:items:BatchAssociateResource' :: [Text]
items = forall a. Monoid a => a
Prelude.mempty
    }

-- | A unique identifier for the resource set, used in a TODO to refer to the
-- resource set.
batchAssociateResource_resourceSetIdentifier :: Lens.Lens' BatchAssociateResource Prelude.Text
batchAssociateResource_resourceSetIdentifier :: Lens' BatchAssociateResource Text
batchAssociateResource_resourceSetIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAssociateResource' {Text
resourceSetIdentifier :: Text
$sel:resourceSetIdentifier:BatchAssociateResource' :: BatchAssociateResource -> Text
resourceSetIdentifier} -> Text
resourceSetIdentifier) (\s :: BatchAssociateResource
s@BatchAssociateResource' {} Text
a -> BatchAssociateResource
s {$sel:resourceSetIdentifier:BatchAssociateResource' :: Text
resourceSetIdentifier = Text
a} :: BatchAssociateResource)

-- | The uniform resource identifiers (URIs) of resources that should be
-- associated to the resource set. The URIs must be Amazon Resource Names
-- (ARNs).
batchAssociateResource_items :: Lens.Lens' BatchAssociateResource [Prelude.Text]
batchAssociateResource_items :: Lens' BatchAssociateResource [Text]
batchAssociateResource_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAssociateResource' {[Text]
items :: [Text]
$sel:items:BatchAssociateResource' :: BatchAssociateResource -> [Text]
items} -> [Text]
items) (\s :: BatchAssociateResource
s@BatchAssociateResource' {} [Text]
a -> BatchAssociateResource
s {$sel:items:BatchAssociateResource' :: [Text]
items = [Text]
a} :: BatchAssociateResource) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.AWSRequest BatchAssociateResource where
  type
    AWSResponse BatchAssociateResource =
      BatchAssociateResourceResponse
  request :: (Service -> Service)
-> BatchAssociateResource -> Request BatchAssociateResource
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 BatchAssociateResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchAssociateResource)))
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 -> Text -> [FailedItem] -> BatchAssociateResourceResponse
BatchAssociateResourceResponse'
            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
"ResourceSetIdentifier")
            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
"FailedItems" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable BatchAssociateResource where
  hashWithSalt :: Int -> BatchAssociateResource -> Int
hashWithSalt Int
_salt BatchAssociateResource' {[Text]
Text
items :: [Text]
resourceSetIdentifier :: Text
$sel:items:BatchAssociateResource' :: BatchAssociateResource -> [Text]
$sel:resourceSetIdentifier:BatchAssociateResource' :: BatchAssociateResource -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceSetIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [Text]
items

instance Prelude.NFData BatchAssociateResource where
  rnf :: BatchAssociateResource -> ()
rnf BatchAssociateResource' {[Text]
Text
items :: [Text]
resourceSetIdentifier :: Text
$sel:items:BatchAssociateResource' :: BatchAssociateResource -> [Text]
$sel:resourceSetIdentifier:BatchAssociateResource' :: BatchAssociateResource -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceSetIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [Text]
items

instance Data.ToHeaders BatchAssociateResource where
  toHeaders :: BatchAssociateResource -> 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.BatchAssociateResource" ::
                          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 BatchAssociateResource where
  toJSON :: BatchAssociateResource -> Value
toJSON BatchAssociateResource' {[Text]
Text
items :: [Text]
resourceSetIdentifier :: Text
$sel:items:BatchAssociateResource' :: BatchAssociateResource -> [Text]
$sel:resourceSetIdentifier:BatchAssociateResource' :: BatchAssociateResource -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"ResourceSetIdentifier"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceSetIdentifier
              ),
            forall a. a -> Maybe a
Prelude.Just (Key
"Items" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [Text]
items)
          ]
      )

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

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

-- | /See:/ 'newBatchAssociateResourceResponse' smart constructor.
data BatchAssociateResourceResponse = BatchAssociateResourceResponse'
  { -- | The response's http status code.
    BatchAssociateResourceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A unique identifier for the resource set, used in a TODO to refer to the
    -- resource set.
    BatchAssociateResourceResponse -> Text
resourceSetIdentifier :: Prelude.Text,
    -- | The resources that failed to associate to the resource set.
    BatchAssociateResourceResponse -> [FailedItem]
failedItems :: [FailedItem]
  }
  deriving (BatchAssociateResourceResponse
-> BatchAssociateResourceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchAssociateResourceResponse
-> BatchAssociateResourceResponse -> Bool
$c/= :: BatchAssociateResourceResponse
-> BatchAssociateResourceResponse -> Bool
== :: BatchAssociateResourceResponse
-> BatchAssociateResourceResponse -> Bool
$c== :: BatchAssociateResourceResponse
-> BatchAssociateResourceResponse -> Bool
Prelude.Eq, ReadPrec [BatchAssociateResourceResponse]
ReadPrec BatchAssociateResourceResponse
Int -> ReadS BatchAssociateResourceResponse
ReadS [BatchAssociateResourceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [BatchAssociateResourceResponse]
$creadListPrec :: ReadPrec [BatchAssociateResourceResponse]
readPrec :: ReadPrec BatchAssociateResourceResponse
$creadPrec :: ReadPrec BatchAssociateResourceResponse
readList :: ReadS [BatchAssociateResourceResponse]
$creadList :: ReadS [BatchAssociateResourceResponse]
readsPrec :: Int -> ReadS BatchAssociateResourceResponse
$creadsPrec :: Int -> ReadS BatchAssociateResourceResponse
Prelude.Read, Int -> BatchAssociateResourceResponse -> ShowS
[BatchAssociateResourceResponse] -> ShowS
BatchAssociateResourceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchAssociateResourceResponse] -> ShowS
$cshowList :: [BatchAssociateResourceResponse] -> ShowS
show :: BatchAssociateResourceResponse -> String
$cshow :: BatchAssociateResourceResponse -> String
showsPrec :: Int -> BatchAssociateResourceResponse -> ShowS
$cshowsPrec :: Int -> BatchAssociateResourceResponse -> ShowS
Prelude.Show, forall x.
Rep BatchAssociateResourceResponse x
-> BatchAssociateResourceResponse
forall x.
BatchAssociateResourceResponse
-> Rep BatchAssociateResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchAssociateResourceResponse x
-> BatchAssociateResourceResponse
$cfrom :: forall x.
BatchAssociateResourceResponse
-> Rep BatchAssociateResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchAssociateResourceResponse' 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', 'batchAssociateResourceResponse_httpStatus' - The response's http status code.
--
-- 'resourceSetIdentifier', 'batchAssociateResourceResponse_resourceSetIdentifier' - A unique identifier for the resource set, used in a TODO to refer to the
-- resource set.
--
-- 'failedItems', 'batchAssociateResourceResponse_failedItems' - The resources that failed to associate to the resource set.
newBatchAssociateResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'resourceSetIdentifier'
  Prelude.Text ->
  BatchAssociateResourceResponse
newBatchAssociateResourceResponse :: Int -> Text -> BatchAssociateResourceResponse
newBatchAssociateResourceResponse
  Int
pHttpStatus_
  Text
pResourceSetIdentifier_ =
    BatchAssociateResourceResponse'
      { $sel:httpStatus:BatchAssociateResourceResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:resourceSetIdentifier:BatchAssociateResourceResponse' :: Text
resourceSetIdentifier =
          Text
pResourceSetIdentifier_,
        $sel:failedItems:BatchAssociateResourceResponse' :: [FailedItem]
failedItems = forall a. Monoid a => a
Prelude.mempty
      }

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

-- | A unique identifier for the resource set, used in a TODO to refer to the
-- resource set.
batchAssociateResourceResponse_resourceSetIdentifier :: Lens.Lens' BatchAssociateResourceResponse Prelude.Text
batchAssociateResourceResponse_resourceSetIdentifier :: Lens' BatchAssociateResourceResponse Text
batchAssociateResourceResponse_resourceSetIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAssociateResourceResponse' {Text
resourceSetIdentifier :: Text
$sel:resourceSetIdentifier:BatchAssociateResourceResponse' :: BatchAssociateResourceResponse -> Text
resourceSetIdentifier} -> Text
resourceSetIdentifier) (\s :: BatchAssociateResourceResponse
s@BatchAssociateResourceResponse' {} Text
a -> BatchAssociateResourceResponse
s {$sel:resourceSetIdentifier:BatchAssociateResourceResponse' :: Text
resourceSetIdentifier = Text
a} :: BatchAssociateResourceResponse)

-- | The resources that failed to associate to the resource set.
batchAssociateResourceResponse_failedItems :: Lens.Lens' BatchAssociateResourceResponse [FailedItem]
batchAssociateResourceResponse_failedItems :: Lens' BatchAssociateResourceResponse [FailedItem]
batchAssociateResourceResponse_failedItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchAssociateResourceResponse' {[FailedItem]
failedItems :: [FailedItem]
$sel:failedItems:BatchAssociateResourceResponse' :: BatchAssociateResourceResponse -> [FailedItem]
failedItems} -> [FailedItem]
failedItems) (\s :: BatchAssociateResourceResponse
s@BatchAssociateResourceResponse' {} [FailedItem]
a -> BatchAssociateResourceResponse
s {$sel:failedItems:BatchAssociateResourceResponse' :: [FailedItem]
failedItems = [FailedItem]
a} :: BatchAssociateResourceResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Prelude.NFData
    BatchAssociateResourceResponse
  where
  rnf :: BatchAssociateResourceResponse -> ()
rnf BatchAssociateResourceResponse' {Int
[FailedItem]
Text
failedItems :: [FailedItem]
resourceSetIdentifier :: Text
httpStatus :: Int
$sel:failedItems:BatchAssociateResourceResponse' :: BatchAssociateResourceResponse -> [FailedItem]
$sel:resourceSetIdentifier:BatchAssociateResourceResponse' :: BatchAssociateResourceResponse -> Text
$sel:httpStatus:BatchAssociateResourceResponse' :: BatchAssociateResourceResponse -> 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 Text
resourceSetIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [FailedItem]
failedItems