{-# 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.DeleteFacet
-- 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 a given Facet. All attributes and Rules that are associated with
-- the facet will be deleted. Only development schema facets are allowed
-- deletion.
module Amazonka.CloudDirectory.DeleteFacet
  ( -- * Creating a Request
    DeleteFacet (..),
    newDeleteFacet,

    -- * Request Lenses
    deleteFacet_schemaArn,
    deleteFacet_name,

    -- * Destructuring the Response
    DeleteFacetResponse (..),
    newDeleteFacetResponse,

    -- * Response Lenses
    deleteFacetResponse_httpStatus,
  )
where

import Amazonka.CloudDirectory.Types
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteFacet' smart constructor.
data DeleteFacet = DeleteFacet'
  { -- | The Amazon Resource Name (ARN) that is associated with the Facet. For
    -- more information, see arns.
    DeleteFacet -> Text
schemaArn :: Prelude.Text,
    -- | The name of the facet to delete.
    DeleteFacet -> Text
name :: Prelude.Text
  }
  deriving (DeleteFacet -> DeleteFacet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteFacet -> DeleteFacet -> Bool
$c/= :: DeleteFacet -> DeleteFacet -> Bool
== :: DeleteFacet -> DeleteFacet -> Bool
$c== :: DeleteFacet -> DeleteFacet -> Bool
Prelude.Eq, ReadPrec [DeleteFacet]
ReadPrec DeleteFacet
Int -> ReadS DeleteFacet
ReadS [DeleteFacet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteFacet]
$creadListPrec :: ReadPrec [DeleteFacet]
readPrec :: ReadPrec DeleteFacet
$creadPrec :: ReadPrec DeleteFacet
readList :: ReadS [DeleteFacet]
$creadList :: ReadS [DeleteFacet]
readsPrec :: Int -> ReadS DeleteFacet
$creadsPrec :: Int -> ReadS DeleteFacet
Prelude.Read, Int -> DeleteFacet -> ShowS
[DeleteFacet] -> ShowS
DeleteFacet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteFacet] -> ShowS
$cshowList :: [DeleteFacet] -> ShowS
show :: DeleteFacet -> String
$cshow :: DeleteFacet -> String
showsPrec :: Int -> DeleteFacet -> ShowS
$cshowsPrec :: Int -> DeleteFacet -> ShowS
Prelude.Show, forall x. Rep DeleteFacet x -> DeleteFacet
forall x. DeleteFacet -> Rep DeleteFacet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteFacet x -> DeleteFacet
$cfrom :: forall x. DeleteFacet -> Rep DeleteFacet x
Prelude.Generic)

-- |
-- Create a value of 'DeleteFacet' 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:
--
-- 'schemaArn', 'deleteFacet_schemaArn' - The Amazon Resource Name (ARN) that is associated with the Facet. For
-- more information, see arns.
--
-- 'name', 'deleteFacet_name' - The name of the facet to delete.
newDeleteFacet ::
  -- | 'schemaArn'
  Prelude.Text ->
  -- | 'name'
  Prelude.Text ->
  DeleteFacet
newDeleteFacet :: Text -> Text -> DeleteFacet
newDeleteFacet Text
pSchemaArn_ Text
pName_ =
  DeleteFacet'
    { $sel:schemaArn:DeleteFacet' :: Text
schemaArn = Text
pSchemaArn_,
      $sel:name:DeleteFacet' :: Text
name = Text
pName_
    }

-- | The Amazon Resource Name (ARN) that is associated with the Facet. For
-- more information, see arns.
deleteFacet_schemaArn :: Lens.Lens' DeleteFacet Prelude.Text
deleteFacet_schemaArn :: Lens' DeleteFacet Text
deleteFacet_schemaArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFacet' {Text
schemaArn :: Text
$sel:schemaArn:DeleteFacet' :: DeleteFacet -> Text
schemaArn} -> Text
schemaArn) (\s :: DeleteFacet
s@DeleteFacet' {} Text
a -> DeleteFacet
s {$sel:schemaArn:DeleteFacet' :: Text
schemaArn = Text
a} :: DeleteFacet)

-- | The name of the facet to delete.
deleteFacet_name :: Lens.Lens' DeleteFacet Prelude.Text
deleteFacet_name :: Lens' DeleteFacet Text
deleteFacet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteFacet' {Text
name :: Text
$sel:name:DeleteFacet' :: DeleteFacet -> Text
name} -> Text
name) (\s :: DeleteFacet
s@DeleteFacet' {} Text
a -> DeleteFacet
s {$sel:name:DeleteFacet' :: Text
name = Text
a} :: DeleteFacet)

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

instance Prelude.Hashable DeleteFacet where
  hashWithSalt :: Int -> DeleteFacet -> Int
hashWithSalt Int
_salt DeleteFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:DeleteFacet' :: DeleteFacet -> Text
$sel:schemaArn:DeleteFacet' :: DeleteFacet -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
schemaArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name

instance Prelude.NFData DeleteFacet where
  rnf :: DeleteFacet -> ()
rnf DeleteFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:DeleteFacet' :: DeleteFacet -> Text
$sel:schemaArn:DeleteFacet' :: DeleteFacet -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
schemaArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name

instance Data.ToHeaders DeleteFacet where
  toHeaders :: DeleteFacet -> ResponseHeaders
toHeaders DeleteFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:DeleteFacet' :: DeleteFacet -> Text
$sel:schemaArn:DeleteFacet' :: DeleteFacet -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [HeaderName
"x-amz-data-partition" forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# Text
schemaArn]

instance Data.ToJSON DeleteFacet where
  toJSON :: DeleteFacet -> Value
toJSON DeleteFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:DeleteFacet' :: DeleteFacet -> Text
$sel:schemaArn:DeleteFacet' :: DeleteFacet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name)]
      )

instance Data.ToPath DeleteFacet where
  toPath :: DeleteFacet -> ByteString
toPath =
    forall a b. a -> b -> a
Prelude.const
      ByteString
"/amazonclouddirectory/2017-01-11/facet/delete"

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

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

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

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

instance Prelude.NFData DeleteFacetResponse where
  rnf :: DeleteFacetResponse -> ()
rnf DeleteFacetResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteFacetResponse' :: DeleteFacetResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus