{-# 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.CloudDirectory.RemoveFacetFromObject
-- 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)
--
-- Removes the specified facet from the specified object.
module Amazonka.CloudDirectory.RemoveFacetFromObject
  ( -- * Creating a Request
    RemoveFacetFromObject (..),
    newRemoveFacetFromObject,

    -- * Request Lenses
    removeFacetFromObject_directoryArn,
    removeFacetFromObject_schemaFacet,
    removeFacetFromObject_objectReference,

    -- * Destructuring the Response
    RemoveFacetFromObjectResponse (..),
    newRemoveFacetFromObjectResponse,

    -- * Response Lenses
    removeFacetFromObjectResponse_httpStatus,
  )
where

import Amazonka.CloudDirectory.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newRemoveFacetFromObject' smart constructor.
data RemoveFacetFromObject = RemoveFacetFromObject'
  { -- | The ARN of the directory in which the object resides.
    RemoveFacetFromObject -> Text
directoryArn :: Prelude.Text,
    -- | The facet to remove. See SchemaFacet for details.
    RemoveFacetFromObject -> SchemaFacet
schemaFacet :: SchemaFacet,
    -- | A reference to the object to remove the facet from.
    RemoveFacetFromObject -> ObjectReference
objectReference :: ObjectReference
  }
  deriving (RemoveFacetFromObject -> RemoveFacetFromObject -> Bool
(RemoveFacetFromObject -> RemoveFacetFromObject -> Bool)
-> (RemoveFacetFromObject -> RemoveFacetFromObject -> Bool)
-> Eq RemoveFacetFromObject
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveFacetFromObject -> RemoveFacetFromObject -> Bool
$c/= :: RemoveFacetFromObject -> RemoveFacetFromObject -> Bool
== :: RemoveFacetFromObject -> RemoveFacetFromObject -> Bool
$c== :: RemoveFacetFromObject -> RemoveFacetFromObject -> Bool
Prelude.Eq, ReadPrec [RemoveFacetFromObject]
ReadPrec RemoveFacetFromObject
Int -> ReadS RemoveFacetFromObject
ReadS [RemoveFacetFromObject]
(Int -> ReadS RemoveFacetFromObject)
-> ReadS [RemoveFacetFromObject]
-> ReadPrec RemoveFacetFromObject
-> ReadPrec [RemoveFacetFromObject]
-> Read RemoveFacetFromObject
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveFacetFromObject]
$creadListPrec :: ReadPrec [RemoveFacetFromObject]
readPrec :: ReadPrec RemoveFacetFromObject
$creadPrec :: ReadPrec RemoveFacetFromObject
readList :: ReadS [RemoveFacetFromObject]
$creadList :: ReadS [RemoveFacetFromObject]
readsPrec :: Int -> ReadS RemoveFacetFromObject
$creadsPrec :: Int -> ReadS RemoveFacetFromObject
Prelude.Read, Int -> RemoveFacetFromObject -> ShowS
[RemoveFacetFromObject] -> ShowS
RemoveFacetFromObject -> String
(Int -> RemoveFacetFromObject -> ShowS)
-> (RemoveFacetFromObject -> String)
-> ([RemoveFacetFromObject] -> ShowS)
-> Show RemoveFacetFromObject
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveFacetFromObject] -> ShowS
$cshowList :: [RemoveFacetFromObject] -> ShowS
show :: RemoveFacetFromObject -> String
$cshow :: RemoveFacetFromObject -> String
showsPrec :: Int -> RemoveFacetFromObject -> ShowS
$cshowsPrec :: Int -> RemoveFacetFromObject -> ShowS
Prelude.Show, (forall x. RemoveFacetFromObject -> Rep RemoveFacetFromObject x)
-> (forall x. Rep RemoveFacetFromObject x -> RemoveFacetFromObject)
-> Generic RemoveFacetFromObject
forall x. Rep RemoveFacetFromObject x -> RemoveFacetFromObject
forall x. RemoveFacetFromObject -> Rep RemoveFacetFromObject x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RemoveFacetFromObject x -> RemoveFacetFromObject
$cfrom :: forall x. RemoveFacetFromObject -> Rep RemoveFacetFromObject x
Prelude.Generic)

-- |
-- Create a value of 'RemoveFacetFromObject' 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:
--
-- 'directoryArn', 'removeFacetFromObject_directoryArn' - The ARN of the directory in which the object resides.
--
-- 'schemaFacet', 'removeFacetFromObject_schemaFacet' - The facet to remove. See SchemaFacet for details.
--
-- 'objectReference', 'removeFacetFromObject_objectReference' - A reference to the object to remove the facet from.
newRemoveFacetFromObject ::
  -- | 'directoryArn'
  Prelude.Text ->
  -- | 'schemaFacet'
  SchemaFacet ->
  -- | 'objectReference'
  ObjectReference ->
  RemoveFacetFromObject
newRemoveFacetFromObject :: Text -> SchemaFacet -> ObjectReference -> RemoveFacetFromObject
newRemoveFacetFromObject
  Text
pDirectoryArn_
  SchemaFacet
pSchemaFacet_
  ObjectReference
pObjectReference_ =
    RemoveFacetFromObject' :: Text -> SchemaFacet -> ObjectReference -> RemoveFacetFromObject
RemoveFacetFromObject'
      { $sel:directoryArn:RemoveFacetFromObject' :: Text
directoryArn =
          Text
pDirectoryArn_,
        $sel:schemaFacet:RemoveFacetFromObject' :: SchemaFacet
schemaFacet = SchemaFacet
pSchemaFacet_,
        $sel:objectReference:RemoveFacetFromObject' :: ObjectReference
objectReference = ObjectReference
pObjectReference_
      }

-- | The ARN of the directory in which the object resides.
removeFacetFromObject_directoryArn :: Lens.Lens' RemoveFacetFromObject Prelude.Text
removeFacetFromObject_directoryArn :: (Text -> f Text)
-> RemoveFacetFromObject -> f RemoveFacetFromObject
removeFacetFromObject_directoryArn = (RemoveFacetFromObject -> Text)
-> (RemoveFacetFromObject -> Text -> RemoveFacetFromObject)
-> Lens RemoveFacetFromObject RemoveFacetFromObject Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFacetFromObject' {Text
directoryArn :: Text
$sel:directoryArn:RemoveFacetFromObject' :: RemoveFacetFromObject -> Text
directoryArn} -> Text
directoryArn) (\s :: RemoveFacetFromObject
s@RemoveFacetFromObject' {} Text
a -> RemoveFacetFromObject
s {$sel:directoryArn:RemoveFacetFromObject' :: Text
directoryArn = Text
a} :: RemoveFacetFromObject)

-- | The facet to remove. See SchemaFacet for details.
removeFacetFromObject_schemaFacet :: Lens.Lens' RemoveFacetFromObject SchemaFacet
removeFacetFromObject_schemaFacet :: (SchemaFacet -> f SchemaFacet)
-> RemoveFacetFromObject -> f RemoveFacetFromObject
removeFacetFromObject_schemaFacet = (RemoveFacetFromObject -> SchemaFacet)
-> (RemoveFacetFromObject -> SchemaFacet -> RemoveFacetFromObject)
-> Lens
     RemoveFacetFromObject RemoveFacetFromObject SchemaFacet SchemaFacet
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFacetFromObject' {SchemaFacet
schemaFacet :: SchemaFacet
$sel:schemaFacet:RemoveFacetFromObject' :: RemoveFacetFromObject -> SchemaFacet
schemaFacet} -> SchemaFacet
schemaFacet) (\s :: RemoveFacetFromObject
s@RemoveFacetFromObject' {} SchemaFacet
a -> RemoveFacetFromObject
s {$sel:schemaFacet:RemoveFacetFromObject' :: SchemaFacet
schemaFacet = SchemaFacet
a} :: RemoveFacetFromObject)

-- | A reference to the object to remove the facet from.
removeFacetFromObject_objectReference :: Lens.Lens' RemoveFacetFromObject ObjectReference
removeFacetFromObject_objectReference :: (ObjectReference -> f ObjectReference)
-> RemoveFacetFromObject -> f RemoveFacetFromObject
removeFacetFromObject_objectReference = (RemoveFacetFromObject -> ObjectReference)
-> (RemoveFacetFromObject
    -> ObjectReference -> RemoveFacetFromObject)
-> Lens
     RemoveFacetFromObject
     RemoveFacetFromObject
     ObjectReference
     ObjectReference
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RemoveFacetFromObject' {ObjectReference
objectReference :: ObjectReference
$sel:objectReference:RemoveFacetFromObject' :: RemoveFacetFromObject -> ObjectReference
objectReference} -> ObjectReference
objectReference) (\s :: RemoveFacetFromObject
s@RemoveFacetFromObject' {} ObjectReference
a -> RemoveFacetFromObject
s {$sel:objectReference:RemoveFacetFromObject' :: ObjectReference
objectReference = ObjectReference
a} :: RemoveFacetFromObject)

instance Core.AWSRequest RemoveFacetFromObject where
  type
    AWSResponse RemoveFacetFromObject =
      RemoveFacetFromObjectResponse
  request :: RemoveFacetFromObject -> Request RemoveFacetFromObject
request = Service -> RemoveFacetFromObject -> Request RemoveFacetFromObject
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RemoveFacetFromObject
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveFacetFromObject)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RemoveFacetFromObject))
-> Logger
-> Service
-> Proxy RemoveFacetFromObject
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse RemoveFacetFromObject)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> RemoveFacetFromObjectResponse
RemoveFacetFromObjectResponse'
            (Int -> RemoveFacetFromObjectResponse)
-> Either String Int -> Either String RemoveFacetFromObjectResponse
forall (f :: * -> *) a b. Functor 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 RemoveFacetFromObject

instance Prelude.NFData RemoveFacetFromObject

instance Core.ToHeaders RemoveFacetFromObject where
  toHeaders :: RemoveFacetFromObject -> ResponseHeaders
toHeaders RemoveFacetFromObject' {Text
ObjectReference
SchemaFacet
objectReference :: ObjectReference
schemaFacet :: SchemaFacet
directoryArn :: Text
$sel:objectReference:RemoveFacetFromObject' :: RemoveFacetFromObject -> ObjectReference
$sel:schemaFacet:RemoveFacetFromObject' :: RemoveFacetFromObject -> SchemaFacet
$sel:directoryArn:RemoveFacetFromObject' :: RemoveFacetFromObject -> Text
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-data-partition" HeaderName -> Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Text
directoryArn]

instance Core.ToJSON RemoveFacetFromObject where
  toJSON :: RemoveFacetFromObject -> Value
toJSON RemoveFacetFromObject' {Text
ObjectReference
SchemaFacet
objectReference :: ObjectReference
schemaFacet :: SchemaFacet
directoryArn :: Text
$sel:objectReference:RemoveFacetFromObject' :: RemoveFacetFromObject -> ObjectReference
$sel:schemaFacet:RemoveFacetFromObject' :: RemoveFacetFromObject -> SchemaFacet
$sel:directoryArn:RemoveFacetFromObject' :: RemoveFacetFromObject -> 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
"SchemaFacet" Text -> SchemaFacet -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SchemaFacet
schemaFacet),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ObjectReference" Text -> ObjectReference -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ObjectReference
objectReference)
          ]
      )

instance Core.ToPath RemoveFacetFromObject where
  toPath :: RemoveFacetFromObject -> ByteString
toPath =
    ByteString -> RemoveFacetFromObject -> ByteString
forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/object/facets/delete"

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

-- | /See:/ 'newRemoveFacetFromObjectResponse' smart constructor.
data RemoveFacetFromObjectResponse = RemoveFacetFromObjectResponse'
  { -- | The response's http status code.
    RemoveFacetFromObjectResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RemoveFacetFromObjectResponse
-> RemoveFacetFromObjectResponse -> Bool
(RemoveFacetFromObjectResponse
 -> RemoveFacetFromObjectResponse -> Bool)
-> (RemoveFacetFromObjectResponse
    -> RemoveFacetFromObjectResponse -> Bool)
-> Eq RemoveFacetFromObjectResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RemoveFacetFromObjectResponse
-> RemoveFacetFromObjectResponse -> Bool
$c/= :: RemoveFacetFromObjectResponse
-> RemoveFacetFromObjectResponse -> Bool
== :: RemoveFacetFromObjectResponse
-> RemoveFacetFromObjectResponse -> Bool
$c== :: RemoveFacetFromObjectResponse
-> RemoveFacetFromObjectResponse -> Bool
Prelude.Eq, ReadPrec [RemoveFacetFromObjectResponse]
ReadPrec RemoveFacetFromObjectResponse
Int -> ReadS RemoveFacetFromObjectResponse
ReadS [RemoveFacetFromObjectResponse]
(Int -> ReadS RemoveFacetFromObjectResponse)
-> ReadS [RemoveFacetFromObjectResponse]
-> ReadPrec RemoveFacetFromObjectResponse
-> ReadPrec [RemoveFacetFromObjectResponse]
-> Read RemoveFacetFromObjectResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RemoveFacetFromObjectResponse]
$creadListPrec :: ReadPrec [RemoveFacetFromObjectResponse]
readPrec :: ReadPrec RemoveFacetFromObjectResponse
$creadPrec :: ReadPrec RemoveFacetFromObjectResponse
readList :: ReadS [RemoveFacetFromObjectResponse]
$creadList :: ReadS [RemoveFacetFromObjectResponse]
readsPrec :: Int -> ReadS RemoveFacetFromObjectResponse
$creadsPrec :: Int -> ReadS RemoveFacetFromObjectResponse
Prelude.Read, Int -> RemoveFacetFromObjectResponse -> ShowS
[RemoveFacetFromObjectResponse] -> ShowS
RemoveFacetFromObjectResponse -> String
(Int -> RemoveFacetFromObjectResponse -> ShowS)
-> (RemoveFacetFromObjectResponse -> String)
-> ([RemoveFacetFromObjectResponse] -> ShowS)
-> Show RemoveFacetFromObjectResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RemoveFacetFromObjectResponse] -> ShowS
$cshowList :: [RemoveFacetFromObjectResponse] -> ShowS
show :: RemoveFacetFromObjectResponse -> String
$cshow :: RemoveFacetFromObjectResponse -> String
showsPrec :: Int -> RemoveFacetFromObjectResponse -> ShowS
$cshowsPrec :: Int -> RemoveFacetFromObjectResponse -> ShowS
Prelude.Show, (forall x.
 RemoveFacetFromObjectResponse
 -> Rep RemoveFacetFromObjectResponse x)
-> (forall x.
    Rep RemoveFacetFromObjectResponse x
    -> RemoveFacetFromObjectResponse)
-> Generic RemoveFacetFromObjectResponse
forall x.
Rep RemoveFacetFromObjectResponse x
-> RemoveFacetFromObjectResponse
forall x.
RemoveFacetFromObjectResponse
-> Rep RemoveFacetFromObjectResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep RemoveFacetFromObjectResponse x
-> RemoveFacetFromObjectResponse
$cfrom :: forall x.
RemoveFacetFromObjectResponse
-> Rep RemoveFacetFromObjectResponse x
Prelude.Generic)

-- |
-- Create a value of 'RemoveFacetFromObjectResponse' 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', 'removeFacetFromObjectResponse_httpStatus' - The response's http status code.
newRemoveFacetFromObjectResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RemoveFacetFromObjectResponse
newRemoveFacetFromObjectResponse :: Int -> RemoveFacetFromObjectResponse
newRemoveFacetFromObjectResponse Int
pHttpStatus_ =
  RemoveFacetFromObjectResponse' :: Int -> RemoveFacetFromObjectResponse
RemoveFacetFromObjectResponse'
    { $sel:httpStatus:RemoveFacetFromObjectResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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

instance Prelude.NFData RemoveFacetFromObjectResponse