{-# 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.Rekognition.DeleteFaces
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes faces from a collection. You specify a collection ID and an
-- array of face IDs to remove from the collection.
--
-- This operation requires permissions to perform the
-- @rekognition:DeleteFaces@ action.
module Amazonka.Rekognition.DeleteFaces
  ( -- * Creating a Request
    DeleteFaces (..),
    newDeleteFaces,

    -- * Request Lenses
    deleteFaces_collectionId,
    deleteFaces_faceIds,

    -- * Destructuring the Response
    DeleteFacesResponse (..),
    newDeleteFacesResponse,

    -- * Response Lenses
    deleteFacesResponse_deletedFaces,
    deleteFacesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.Rekognition.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteFaces' smart constructor.
data DeleteFaces = DeleteFaces'
  { -- | Collection from which to remove the specific faces.
    DeleteFaces -> Text
collectionId :: Prelude.Text,
    -- | An array of face IDs to delete.
    DeleteFaces -> NonEmpty Text
faceIds :: Prelude.NonEmpty Prelude.Text
  }
  deriving (DeleteFaces -> DeleteFaces -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFaces -> DeleteFaces -> Bool
$c/= :: DeleteFaces -> DeleteFaces -> Bool
== :: DeleteFaces -> DeleteFaces -> Bool
$c== :: DeleteFaces -> DeleteFaces -> Bool
Prelude.Eq, ReadPrec [DeleteFaces]
ReadPrec DeleteFaces
Int -> ReadS DeleteFaces
ReadS [DeleteFaces]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFaces]
$creadListPrec :: ReadPrec [DeleteFaces]
readPrec :: ReadPrec DeleteFaces
$creadPrec :: ReadPrec DeleteFaces
readList :: ReadS [DeleteFaces]
$creadList :: ReadS [DeleteFaces]
readsPrec :: Int -> ReadS DeleteFaces
$creadsPrec :: Int -> ReadS DeleteFaces
Prelude.Read, Int -> DeleteFaces -> ShowS
[DeleteFaces] -> ShowS
DeleteFaces -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFaces] -> ShowS
$cshowList :: [DeleteFaces] -> ShowS
show :: DeleteFaces -> String
$cshow :: DeleteFaces -> String
showsPrec :: Int -> DeleteFaces -> ShowS
$cshowsPrec :: Int -> DeleteFaces -> ShowS
Prelude.Show, forall x. Rep DeleteFaces x -> DeleteFaces
forall x. DeleteFaces -> Rep DeleteFaces x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFaces x -> DeleteFaces
$cfrom :: forall x. DeleteFaces -> Rep DeleteFaces x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFaces' 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:
--
-- 'collectionId', 'deleteFaces_collectionId' - Collection from which to remove the specific faces.
--
-- 'faceIds', 'deleteFaces_faceIds' - An array of face IDs to delete.
newDeleteFaces ::
  -- | 'collectionId'
  Prelude.Text ->
  -- | 'faceIds'
  Prelude.NonEmpty Prelude.Text ->
  DeleteFaces
newDeleteFaces :: Text -> NonEmpty Text -> DeleteFaces
newDeleteFaces Text
pCollectionId_ NonEmpty Text
pFaceIds_ =
  DeleteFaces'
    { $sel:collectionId:DeleteFaces' :: Text
collectionId = Text
pCollectionId_,
      $sel:faceIds:DeleteFaces' :: NonEmpty Text
faceIds = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pFaceIds_
    }

-- | Collection from which to remove the specific faces.
deleteFaces_collectionId :: Lens.Lens' DeleteFaces Prelude.Text
deleteFaces_collectionId :: Lens' DeleteFaces Text
deleteFaces_collectionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFaces' {Text
collectionId :: Text
$sel:collectionId:DeleteFaces' :: DeleteFaces -> Text
collectionId} -> Text
collectionId) (\s :: DeleteFaces
s@DeleteFaces' {} Text
a -> DeleteFaces
s {$sel:collectionId:DeleteFaces' :: Text
collectionId = Text
a} :: DeleteFaces)

-- | An array of face IDs to delete.
deleteFaces_faceIds :: Lens.Lens' DeleteFaces (Prelude.NonEmpty Prelude.Text)
deleteFaces_faceIds :: Lens' DeleteFaces (NonEmpty Text)
deleteFaces_faceIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFaces' {NonEmpty Text
faceIds :: NonEmpty Text
$sel:faceIds:DeleteFaces' :: DeleteFaces -> NonEmpty Text
faceIds} -> NonEmpty Text
faceIds) (\s :: DeleteFaces
s@DeleteFaces' {} NonEmpty Text
a -> DeleteFaces
s {$sel:faceIds:DeleteFaces' :: NonEmpty Text
faceIds = NonEmpty Text
a} :: DeleteFaces) 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 DeleteFaces where
  type AWSResponse DeleteFaces = DeleteFacesResponse
  request :: (Service -> Service) -> DeleteFaces -> Request DeleteFaces
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 DeleteFaces
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFaces)))
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 (NonEmpty Text) -> Int -> DeleteFacesResponse
DeleteFacesResponse'
            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
"DeletedFaces")
            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 DeleteFaces where
  hashWithSalt :: Int -> DeleteFaces -> Int
hashWithSalt Int
_salt DeleteFaces' {NonEmpty Text
Text
faceIds :: NonEmpty Text
collectionId :: Text
$sel:faceIds:DeleteFaces' :: DeleteFaces -> NonEmpty Text
$sel:collectionId:DeleteFaces' :: DeleteFaces -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
collectionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
faceIds

instance Prelude.NFData DeleteFaces where
  rnf :: DeleteFaces -> ()
rnf DeleteFaces' {NonEmpty Text
Text
faceIds :: NonEmpty Text
collectionId :: Text
$sel:faceIds:DeleteFaces' :: DeleteFaces -> NonEmpty Text
$sel:collectionId:DeleteFaces' :: DeleteFaces -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
collectionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
faceIds

instance Data.ToHeaders DeleteFaces where
  toHeaders :: DeleteFaces -> 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
"RekognitionService.DeleteFaces" ::
                          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 DeleteFaces where
  toJSON :: DeleteFaces -> Value
toJSON DeleteFaces' {NonEmpty Text
Text
faceIds :: NonEmpty Text
collectionId :: Text
$sel:faceIds:DeleteFaces' :: DeleteFaces -> NonEmpty Text
$sel:collectionId:DeleteFaces' :: DeleteFaces -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"CollectionId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
collectionId),
            forall a. a -> Maybe a
Prelude.Just (Key
"FaceIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
faceIds)
          ]
      )

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

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

-- | /See:/ 'newDeleteFacesResponse' smart constructor.
data DeleteFacesResponse = DeleteFacesResponse'
  { -- | An array of strings (face IDs) of the faces that were deleted.
    DeleteFacesResponse -> Maybe (NonEmpty Text)
deletedFaces :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The response's http status code.
    DeleteFacesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteFacesResponse -> DeleteFacesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFacesResponse -> DeleteFacesResponse -> Bool
$c/= :: DeleteFacesResponse -> DeleteFacesResponse -> Bool
== :: DeleteFacesResponse -> DeleteFacesResponse -> Bool
$c== :: DeleteFacesResponse -> DeleteFacesResponse -> Bool
Prelude.Eq, ReadPrec [DeleteFacesResponse]
ReadPrec DeleteFacesResponse
Int -> ReadS DeleteFacesResponse
ReadS [DeleteFacesResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFacesResponse]
$creadListPrec :: ReadPrec [DeleteFacesResponse]
readPrec :: ReadPrec DeleteFacesResponse
$creadPrec :: ReadPrec DeleteFacesResponse
readList :: ReadS [DeleteFacesResponse]
$creadList :: ReadS [DeleteFacesResponse]
readsPrec :: Int -> ReadS DeleteFacesResponse
$creadsPrec :: Int -> ReadS DeleteFacesResponse
Prelude.Read, Int -> DeleteFacesResponse -> ShowS
[DeleteFacesResponse] -> ShowS
DeleteFacesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFacesResponse] -> ShowS
$cshowList :: [DeleteFacesResponse] -> ShowS
show :: DeleteFacesResponse -> String
$cshow :: DeleteFacesResponse -> String
showsPrec :: Int -> DeleteFacesResponse -> ShowS
$cshowsPrec :: Int -> DeleteFacesResponse -> ShowS
Prelude.Show, forall x. Rep DeleteFacesResponse x -> DeleteFacesResponse
forall x. DeleteFacesResponse -> Rep DeleteFacesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFacesResponse x -> DeleteFacesResponse
$cfrom :: forall x. DeleteFacesResponse -> Rep DeleteFacesResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFacesResponse' 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:
--
-- 'deletedFaces', 'deleteFacesResponse_deletedFaces' - An array of strings (face IDs) of the faces that were deleted.
--
-- 'httpStatus', 'deleteFacesResponse_httpStatus' - The response's http status code.
newDeleteFacesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteFacesResponse
newDeleteFacesResponse :: Int -> DeleteFacesResponse
newDeleteFacesResponse Int
pHttpStatus_ =
  DeleteFacesResponse'
    { $sel:deletedFaces:DeleteFacesResponse' :: Maybe (NonEmpty Text)
deletedFaces =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteFacesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of strings (face IDs) of the faces that were deleted.
deleteFacesResponse_deletedFaces :: Lens.Lens' DeleteFacesResponse (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
deleteFacesResponse_deletedFaces :: Lens' DeleteFacesResponse (Maybe (NonEmpty Text))
deleteFacesResponse_deletedFaces = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFacesResponse' {Maybe (NonEmpty Text)
deletedFaces :: Maybe (NonEmpty Text)
$sel:deletedFaces:DeleteFacesResponse' :: DeleteFacesResponse -> Maybe (NonEmpty Text)
deletedFaces} -> Maybe (NonEmpty Text)
deletedFaces) (\s :: DeleteFacesResponse
s@DeleteFacesResponse' {} Maybe (NonEmpty Text)
a -> DeleteFacesResponse
s {$sel:deletedFaces:DeleteFacesResponse' :: Maybe (NonEmpty Text)
deletedFaces = Maybe (NonEmpty Text)
a} :: DeleteFacesResponse) 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 response's http status code.
deleteFacesResponse_httpStatus :: Lens.Lens' DeleteFacesResponse Prelude.Int
deleteFacesResponse_httpStatus :: Lens' DeleteFacesResponse Int
deleteFacesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFacesResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteFacesResponse' :: DeleteFacesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: DeleteFacesResponse
s@DeleteFacesResponse' {} Int
a -> DeleteFacesResponse
s {$sel:httpStatus:DeleteFacesResponse' :: Int
httpStatus = Int
a} :: DeleteFacesResponse)

instance Prelude.NFData DeleteFacesResponse where
  rnf :: DeleteFacesResponse -> ()
rnf DeleteFacesResponse' {Int
Maybe (NonEmpty Text)
httpStatus :: Int
deletedFaces :: Maybe (NonEmpty Text)
$sel:httpStatus:DeleteFacesResponse' :: DeleteFacesResponse -> Int
$sel:deletedFaces:DeleteFacesResponse' :: DeleteFacesResponse -> Maybe (NonEmpty Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Text)
deletedFaces
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus