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

    -- * Request Lenses
    batchDisassociateResource_resourceSetIdentifier,
    batchDisassociateResource_items,

    -- * Destructuring the Response
    BatchDisassociateResourceResponse (..),
    newBatchDisassociateResourceResponse,

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

-- |
-- Create a value of 'BatchDisassociateResource' 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', 'batchDisassociateResource_resourceSetIdentifier' - A unique identifier for the resource set, used in a TODO to refer to the
-- resource set.
--
-- 'items', 'batchDisassociateResource_items' - The uniform resource identifiers (URI) of resources that should be
-- disassociated from the resource set. The URIs must be Amazon Resource
-- Names (ARNs).
newBatchDisassociateResource ::
  -- | 'resourceSetIdentifier'
  Prelude.Text ->
  BatchDisassociateResource
newBatchDisassociateResource :: Text -> BatchDisassociateResource
newBatchDisassociateResource Text
pResourceSetIdentifier_ =
  BatchDisassociateResource'
    { $sel:resourceSetIdentifier:BatchDisassociateResource' :: Text
resourceSetIdentifier =
        Text
pResourceSetIdentifier_,
      $sel:items:BatchDisassociateResource' :: [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.
batchDisassociateResource_resourceSetIdentifier :: Lens.Lens' BatchDisassociateResource Prelude.Text
batchDisassociateResource_resourceSetIdentifier :: Lens' BatchDisassociateResource Text
batchDisassociateResource_resourceSetIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDisassociateResource' {Text
resourceSetIdentifier :: Text
$sel:resourceSetIdentifier:BatchDisassociateResource' :: BatchDisassociateResource -> Text
resourceSetIdentifier} -> Text
resourceSetIdentifier) (\s :: BatchDisassociateResource
s@BatchDisassociateResource' {} Text
a -> BatchDisassociateResource
s {$sel:resourceSetIdentifier:BatchDisassociateResource' :: Text
resourceSetIdentifier = Text
a} :: BatchDisassociateResource)

-- | The uniform resource identifiers (URI) of resources that should be
-- disassociated from the resource set. The URIs must be Amazon Resource
-- Names (ARNs).
batchDisassociateResource_items :: Lens.Lens' BatchDisassociateResource [Prelude.Text]
batchDisassociateResource_items :: Lens' BatchDisassociateResource [Text]
batchDisassociateResource_items = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDisassociateResource' {[Text]
items :: [Text]
$sel:items:BatchDisassociateResource' :: BatchDisassociateResource -> [Text]
items} -> [Text]
items) (\s :: BatchDisassociateResource
s@BatchDisassociateResource' {} [Text]
a -> BatchDisassociateResource
s {$sel:items:BatchDisassociateResource' :: [Text]
items = [Text]
a} :: BatchDisassociateResource) 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 BatchDisassociateResource where
  type
    AWSResponse BatchDisassociateResource =
      BatchDisassociateResourceResponse
  request :: (Service -> Service)
-> BatchDisassociateResource -> Request BatchDisassociateResource
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 BatchDisassociateResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchDisassociateResource)))
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] -> BatchDisassociateResourceResponse
BatchDisassociateResourceResponse'
            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 BatchDisassociateResource where
  hashWithSalt :: Int -> BatchDisassociateResource -> Int
hashWithSalt Int
_salt BatchDisassociateResource' {[Text]
Text
items :: [Text]
resourceSetIdentifier :: Text
$sel:items:BatchDisassociateResource' :: BatchDisassociateResource -> [Text]
$sel:resourceSetIdentifier:BatchDisassociateResource' :: BatchDisassociateResource -> 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 BatchDisassociateResource where
  rnf :: BatchDisassociateResource -> ()
rnf BatchDisassociateResource' {[Text]
Text
items :: [Text]
resourceSetIdentifier :: Text
$sel:items:BatchDisassociateResource' :: BatchDisassociateResource -> [Text]
$sel:resourceSetIdentifier:BatchDisassociateResource' :: BatchDisassociateResource -> 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 BatchDisassociateResource where
  toHeaders :: BatchDisassociateResource -> 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.BatchDisassociateResource" ::
                          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 BatchDisassociateResource where
  toJSON :: BatchDisassociateResource -> Value
toJSON BatchDisassociateResource' {[Text]
Text
items :: [Text]
resourceSetIdentifier :: Text
$sel:items:BatchDisassociateResource' :: BatchDisassociateResource -> [Text]
$sel:resourceSetIdentifier:BatchDisassociateResource' :: BatchDisassociateResource -> 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 BatchDisassociateResource where
  toPath :: BatchDisassociateResource -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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

-- | The resources that failed to disassociate from the resource set.
batchDisassociateResourceResponse_failedItems :: Lens.Lens' BatchDisassociateResourceResponse [FailedItem]
batchDisassociateResourceResponse_failedItems :: Lens' BatchDisassociateResourceResponse [FailedItem]
batchDisassociateResourceResponse_failedItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchDisassociateResourceResponse' {[FailedItem]
failedItems :: [FailedItem]
$sel:failedItems:BatchDisassociateResourceResponse' :: BatchDisassociateResourceResponse -> [FailedItem]
failedItems} -> [FailedItem]
failedItems) (\s :: BatchDisassociateResourceResponse
s@BatchDisassociateResourceResponse' {} [FailedItem]
a -> BatchDisassociateResourceResponse
s {$sel:failedItems:BatchDisassociateResourceResponse' :: [FailedItem]
failedItems = [FailedItem]
a} :: BatchDisassociateResourceResponse) 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
    BatchDisassociateResourceResponse
  where
  rnf :: BatchDisassociateResourceResponse -> ()
rnf BatchDisassociateResourceResponse' {Int
[FailedItem]
Text
failedItems :: [FailedItem]
resourceSetIdentifier :: Text
httpStatus :: Int
$sel:failedItems:BatchDisassociateResourceResponse' :: BatchDisassociateResourceResponse -> [FailedItem]
$sel:resourceSetIdentifier:BatchDisassociateResourceResponse' :: BatchDisassociateResourceResponse -> Text
$sel:httpStatus:BatchDisassociateResourceResponse' :: BatchDisassociateResourceResponse -> 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