{-# 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-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)
--
-- 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.Lens as Lens
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
(DeleteFaces -> DeleteFaces -> Bool)
-> (DeleteFaces -> DeleteFaces -> Bool) -> Eq DeleteFaces
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]
(Int -> ReadS DeleteFaces)
-> ReadS [DeleteFaces]
-> ReadPrec DeleteFaces
-> ReadPrec [DeleteFaces]
-> Read 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
(Int -> DeleteFaces -> ShowS)
-> (DeleteFaces -> String)
-> ([DeleteFaces] -> ShowS)
-> Show DeleteFaces
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. DeleteFaces -> Rep DeleteFaces x)
-> (forall x. Rep DeleteFaces x -> DeleteFaces)
-> Generic DeleteFaces
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' :: Text -> NonEmpty Text -> DeleteFaces
DeleteFaces'
    { $sel:collectionId:DeleteFaces' :: Text
collectionId = Text
pCollectionId_,
      $sel:faceIds:DeleteFaces' :: NonEmpty Text
faceIds = Tagged (NonEmpty Text) (Identity (NonEmpty Text))
-> Tagged (NonEmpty Text) (Identity (NonEmpty Text))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced (Tagged (NonEmpty Text) (Identity (NonEmpty Text))
 -> Tagged (NonEmpty Text) (Identity (NonEmpty Text)))
-> NonEmpty Text -> NonEmpty Text
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 :: (Text -> f Text) -> DeleteFaces -> f DeleteFaces
deleteFaces_collectionId = (DeleteFaces -> Text)
-> (DeleteFaces -> Text -> DeleteFaces)
-> Lens DeleteFaces DeleteFaces Text Text
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 :: (NonEmpty Text -> f (NonEmpty Text))
-> DeleteFaces -> f DeleteFaces
deleteFaces_faceIds = (DeleteFaces -> NonEmpty Text)
-> (DeleteFaces -> NonEmpty Text -> DeleteFaces)
-> Lens DeleteFaces DeleteFaces (NonEmpty Text) (NonEmpty Text)
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) ((NonEmpty Text -> f (NonEmpty Text))
 -> DeleteFaces -> f DeleteFaces)
-> ((NonEmpty Text -> f (NonEmpty Text))
    -> NonEmpty Text -> f (NonEmpty Text))
-> (NonEmpty Text -> f (NonEmpty Text))
-> DeleteFaces
-> f DeleteFaces
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty Text -> f (NonEmpty Text))
-> NonEmpty Text -> f (NonEmpty Text)
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 :: DeleteFaces -> Request DeleteFaces
request = Service -> DeleteFaces -> Request DeleteFaces
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteFaces
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFaces)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteFaces))
-> Logger
-> Service
-> Proxy DeleteFaces
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFaces)))
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 (NonEmpty Text) -> Int -> DeleteFacesResponse
DeleteFacesResponse'
            (Maybe (NonEmpty Text) -> Int -> DeleteFacesResponse)
-> Either String (Maybe (NonEmpty Text))
-> Either String (Int -> DeleteFacesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (NonEmpty Text))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"DeletedFaces")
            Either String (Int -> DeleteFacesResponse)
-> Either String Int -> Either String DeleteFacesResponse
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 DeleteFaces

instance Prelude.NFData DeleteFaces

instance Core.ToHeaders DeleteFaces where
  toHeaders :: DeleteFaces -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteFaces -> 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
"RekognitionService.DeleteFaces" ::
                          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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"CollectionId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
collectionId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"FaceIds" Text -> NonEmpty Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty Text
faceIds)
          ]
      )

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

instance Core.ToQuery DeleteFaces where
  toQuery :: DeleteFaces -> QueryString
toQuery = QueryString -> DeleteFaces -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteFacesResponse -> DeleteFacesResponse -> Bool)
-> (DeleteFacesResponse -> DeleteFacesResponse -> Bool)
-> Eq DeleteFacesResponse
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]
(Int -> ReadS DeleteFacesResponse)
-> ReadS [DeleteFacesResponse]
-> ReadPrec DeleteFacesResponse
-> ReadPrec [DeleteFacesResponse]
-> Read 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
(Int -> DeleteFacesResponse -> ShowS)
-> (DeleteFacesResponse -> String)
-> ([DeleteFacesResponse] -> ShowS)
-> Show DeleteFacesResponse
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. DeleteFacesResponse -> Rep DeleteFacesResponse x)
-> (forall x. Rep DeleteFacesResponse x -> DeleteFacesResponse)
-> Generic DeleteFacesResponse
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' :: Maybe (NonEmpty Text) -> Int -> DeleteFacesResponse
DeleteFacesResponse'
    { $sel:deletedFaces:DeleteFacesResponse' :: Maybe (NonEmpty Text)
deletedFaces =
        Maybe (NonEmpty Text)
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 :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DeleteFacesResponse -> f DeleteFacesResponse
deleteFacesResponse_deletedFaces = (DeleteFacesResponse -> Maybe (NonEmpty Text))
-> (DeleteFacesResponse
    -> Maybe (NonEmpty Text) -> DeleteFacesResponse)
-> Lens
     DeleteFacesResponse
     DeleteFacesResponse
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> DeleteFacesResponse -> f DeleteFacesResponse)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> DeleteFacesResponse
-> f DeleteFacesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
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 :: (Int -> f Int) -> DeleteFacesResponse -> f DeleteFacesResponse
deleteFacesResponse_httpStatus = (DeleteFacesResponse -> Int)
-> (DeleteFacesResponse -> Int -> DeleteFacesResponse)
-> Lens DeleteFacesResponse DeleteFacesResponse Int Int
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