{-# 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.CustomerProfiles.DeleteDomain
-- 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 specific domain and all of its customer data, such as customer
-- profile attributes and their related objects.
module Amazonka.CustomerProfiles.DeleteDomain
  ( -- * Creating a Request
    DeleteDomain (..),
    newDeleteDomain,

    -- * Request Lenses
    deleteDomain_domainName,

    -- * Destructuring the Response
    DeleteDomainResponse (..),
    newDeleteDomainResponse,

    -- * Response Lenses
    deleteDomainResponse_httpStatus,
    deleteDomainResponse_message,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.CustomerProfiles.Types
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:/ 'newDeleteDomain' smart constructor.
data DeleteDomain = DeleteDomain'
  { -- | The unique name of the domain.
    DeleteDomain -> Text
domainName :: Prelude.Text
  }
  deriving (DeleteDomain -> DeleteDomain -> Bool
(DeleteDomain -> DeleteDomain -> Bool)
-> (DeleteDomain -> DeleteDomain -> Bool) -> Eq DeleteDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDomain -> DeleteDomain -> Bool
$c/= :: DeleteDomain -> DeleteDomain -> Bool
== :: DeleteDomain -> DeleteDomain -> Bool
$c== :: DeleteDomain -> DeleteDomain -> Bool
Prelude.Eq, ReadPrec [DeleteDomain]
ReadPrec DeleteDomain
Int -> ReadS DeleteDomain
ReadS [DeleteDomain]
(Int -> ReadS DeleteDomain)
-> ReadS [DeleteDomain]
-> ReadPrec DeleteDomain
-> ReadPrec [DeleteDomain]
-> Read DeleteDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDomain]
$creadListPrec :: ReadPrec [DeleteDomain]
readPrec :: ReadPrec DeleteDomain
$creadPrec :: ReadPrec DeleteDomain
readList :: ReadS [DeleteDomain]
$creadList :: ReadS [DeleteDomain]
readsPrec :: Int -> ReadS DeleteDomain
$creadsPrec :: Int -> ReadS DeleteDomain
Prelude.Read, Int -> DeleteDomain -> ShowS
[DeleteDomain] -> ShowS
DeleteDomain -> String
(Int -> DeleteDomain -> ShowS)
-> (DeleteDomain -> String)
-> ([DeleteDomain] -> ShowS)
-> Show DeleteDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDomain] -> ShowS
$cshowList :: [DeleteDomain] -> ShowS
show :: DeleteDomain -> String
$cshow :: DeleteDomain -> String
showsPrec :: Int -> DeleteDomain -> ShowS
$cshowsPrec :: Int -> DeleteDomain -> ShowS
Prelude.Show, (forall x. DeleteDomain -> Rep DeleteDomain x)
-> (forall x. Rep DeleteDomain x -> DeleteDomain)
-> Generic DeleteDomain
forall x. Rep DeleteDomain x -> DeleteDomain
forall x. DeleteDomain -> Rep DeleteDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDomain x -> DeleteDomain
$cfrom :: forall x. DeleteDomain -> Rep DeleteDomain x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDomain' 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:
--
-- 'domainName', 'deleteDomain_domainName' - The unique name of the domain.
newDeleteDomain ::
  -- | 'domainName'
  Prelude.Text ->
  DeleteDomain
newDeleteDomain :: Text -> DeleteDomain
newDeleteDomain Text
pDomainName_ =
  DeleteDomain' :: Text -> DeleteDomain
DeleteDomain' {$sel:domainName:DeleteDomain' :: Text
domainName = Text
pDomainName_}

-- | The unique name of the domain.
deleteDomain_domainName :: Lens.Lens' DeleteDomain Prelude.Text
deleteDomain_domainName :: (Text -> f Text) -> DeleteDomain -> f DeleteDomain
deleteDomain_domainName = (DeleteDomain -> Text)
-> (DeleteDomain -> Text -> DeleteDomain)
-> Lens DeleteDomain DeleteDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomain' {Text
domainName :: Text
$sel:domainName:DeleteDomain' :: DeleteDomain -> Text
domainName} -> Text
domainName) (\s :: DeleteDomain
s@DeleteDomain' {} Text
a -> DeleteDomain
s {$sel:domainName:DeleteDomain' :: Text
domainName = Text
a} :: DeleteDomain)

instance Core.AWSRequest DeleteDomain where
  type AWSResponse DeleteDomain = DeleteDomainResponse
  request :: DeleteDomain -> Request DeleteDomain
request = Service -> DeleteDomain -> Request DeleteDomain
forall a. ToRequest a => Service -> a -> Request a
Request.delete Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDomain)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteDomain))
-> Logger
-> Service
-> Proxy DeleteDomain
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteDomain)))
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 ->
          Int -> Text -> DeleteDomainResponse
DeleteDomainResponse'
            (Int -> Text -> DeleteDomainResponse)
-> Either String Int
-> Either String (Text -> DeleteDomainResponse)
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))
            Either String (Text -> DeleteDomainResponse)
-> Either String Text -> Either String DeleteDomainResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"Message")
      )

instance Prelude.Hashable DeleteDomain

instance Prelude.NFData DeleteDomain

instance Core.ToHeaders DeleteDomain where
  toHeaders :: DeleteDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDomain -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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.ToPath DeleteDomain where
  toPath :: DeleteDomain -> ByteString
toPath DeleteDomain' {Text
domainName :: Text
$sel:domainName:DeleteDomain' :: DeleteDomain -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/domains/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
domainName]

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

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

-- |
-- Create a value of 'DeleteDomainResponse' 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', 'deleteDomainResponse_httpStatus' - The response's http status code.
--
-- 'message', 'deleteDomainResponse_message' - A message that indicates the delete request is done.
newDeleteDomainResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'message'
  Prelude.Text ->
  DeleteDomainResponse
newDeleteDomainResponse :: Int -> Text -> DeleteDomainResponse
newDeleteDomainResponse Int
pHttpStatus_ Text
pMessage_ =
  DeleteDomainResponse' :: Int -> Text -> DeleteDomainResponse
DeleteDomainResponse'
    { $sel:httpStatus:DeleteDomainResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:message:DeleteDomainResponse' :: Text
message = Text
pMessage_
    }

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

-- | A message that indicates the delete request is done.
deleteDomainResponse_message :: Lens.Lens' DeleteDomainResponse Prelude.Text
deleteDomainResponse_message :: (Text -> f Text) -> DeleteDomainResponse -> f DeleteDomainResponse
deleteDomainResponse_message = (DeleteDomainResponse -> Text)
-> (DeleteDomainResponse -> Text -> DeleteDomainResponse)
-> Lens DeleteDomainResponse DeleteDomainResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomainResponse' {Text
message :: Text
$sel:message:DeleteDomainResponse' :: DeleteDomainResponse -> Text
message} -> Text
message) (\s :: DeleteDomainResponse
s@DeleteDomainResponse' {} Text
a -> DeleteDomainResponse
s {$sel:message:DeleteDomainResponse' :: Text
message = Text
a} :: DeleteDomainResponse)

instance Prelude.NFData DeleteDomainResponse