{-# 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-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 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.Lens as Lens
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
(DeleteFacet -> DeleteFacet -> Bool)
-> (DeleteFacet -> DeleteFacet -> Bool) -> Eq DeleteFacet
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]
(Int -> ReadS DeleteFacet)
-> ReadS [DeleteFacet]
-> ReadPrec DeleteFacet
-> ReadPrec [DeleteFacet]
-> Read 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
(Int -> DeleteFacet -> ShowS)
-> (DeleteFacet -> String)
-> ([DeleteFacet] -> ShowS)
-> Show DeleteFacet
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. DeleteFacet -> Rep DeleteFacet x)
-> (forall x. Rep DeleteFacet x -> DeleteFacet)
-> Generic DeleteFacet
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' :: Text -> Text -> DeleteFacet
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 :: (Text -> f Text) -> DeleteFacet -> f DeleteFacet
deleteFacet_schemaArn = (DeleteFacet -> Text)
-> (DeleteFacet -> Text -> DeleteFacet)
-> Lens DeleteFacet DeleteFacet Text Text
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 :: (Text -> f Text) -> DeleteFacet -> f DeleteFacet
deleteFacet_name = (DeleteFacet -> Text)
-> (DeleteFacet -> Text -> DeleteFacet)
-> Lens DeleteFacet DeleteFacet Text Text
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 :: DeleteFacet -> Request DeleteFacet
request = Service -> DeleteFacet -> Request DeleteFacet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteFacet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFacet)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteFacet))
-> Logger
-> Service
-> Proxy DeleteFacet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteFacet)))
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 -> DeleteFacetResponse
DeleteFacetResponse'
            (Int -> DeleteFacetResponse)
-> Either String Int -> Either String DeleteFacetResponse
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 DeleteFacet

instance Prelude.NFData DeleteFacet

instance Core.ToHeaders DeleteFacet where
  toHeaders :: DeleteFacet -> ResponseHeaders
toHeaders DeleteFacet' {Text
name :: Text
schemaArn :: Text
$sel:name:DeleteFacet' :: DeleteFacet -> Text
$sel:schemaArn:DeleteFacet' :: DeleteFacet -> 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
schemaArn]

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name)]
      )

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

instance Core.ToQuery DeleteFacet where
  toQuery :: DeleteFacet -> QueryString
toQuery = QueryString -> DeleteFacet -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteFacetResponse -> DeleteFacetResponse -> Bool)
-> (DeleteFacetResponse -> DeleteFacetResponse -> Bool)
-> Eq DeleteFacetResponse
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]
(Int -> ReadS DeleteFacetResponse)
-> ReadS [DeleteFacetResponse]
-> ReadPrec DeleteFacetResponse
-> ReadPrec [DeleteFacetResponse]
-> Read 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
(Int -> DeleteFacetResponse -> ShowS)
-> (DeleteFacetResponse -> String)
-> ([DeleteFacetResponse] -> ShowS)
-> Show DeleteFacetResponse
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. DeleteFacetResponse -> Rep DeleteFacetResponse x)
-> (forall x. Rep DeleteFacetResponse x -> DeleteFacetResponse)
-> Generic DeleteFacetResponse
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' :: Int -> DeleteFacetResponse
DeleteFacetResponse' {$sel:httpStatus:DeleteFacetResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteFacetResponse_httpStatus :: Lens.Lens' DeleteFacetResponse Prelude.Int
deleteFacetResponse_httpStatus :: (Int -> f Int) -> DeleteFacetResponse -> f DeleteFacetResponse
deleteFacetResponse_httpStatus = (DeleteFacetResponse -> Int)
-> (DeleteFacetResponse -> Int -> DeleteFacetResponse)
-> Lens DeleteFacetResponse DeleteFacetResponse Int Int
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