{-# 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.DeleteProfile
-- 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 the standard customer profile and all data pertaining to the
-- profile.
module Amazonka.CustomerProfiles.DeleteProfile
  ( -- * Creating a Request
    DeleteProfile (..),
    newDeleteProfile,

    -- * Request Lenses
    deleteProfile_profileId,
    deleteProfile_domainName,

    -- * Destructuring the Response
    DeleteProfileResponse (..),
    newDeleteProfileResponse,

    -- * Response Lenses
    deleteProfileResponse_message,
    deleteProfileResponse_httpStatus,
  )
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:/ 'newDeleteProfile' smart constructor.
data DeleteProfile = DeleteProfile'
  { -- | The unique identifier of a customer profile.
    DeleteProfile -> Text
profileId :: Prelude.Text,
    -- | The unique name of the domain.
    DeleteProfile -> Text
domainName :: Prelude.Text
  }
  deriving (DeleteProfile -> DeleteProfile -> Bool
(DeleteProfile -> DeleteProfile -> Bool)
-> (DeleteProfile -> DeleteProfile -> Bool) -> Eq DeleteProfile
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteProfile -> DeleteProfile -> Bool
$c/= :: DeleteProfile -> DeleteProfile -> Bool
== :: DeleteProfile -> DeleteProfile -> Bool
$c== :: DeleteProfile -> DeleteProfile -> Bool
Prelude.Eq, ReadPrec [DeleteProfile]
ReadPrec DeleteProfile
Int -> ReadS DeleteProfile
ReadS [DeleteProfile]
(Int -> ReadS DeleteProfile)
-> ReadS [DeleteProfile]
-> ReadPrec DeleteProfile
-> ReadPrec [DeleteProfile]
-> Read DeleteProfile
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteProfile]
$creadListPrec :: ReadPrec [DeleteProfile]
readPrec :: ReadPrec DeleteProfile
$creadPrec :: ReadPrec DeleteProfile
readList :: ReadS [DeleteProfile]
$creadList :: ReadS [DeleteProfile]
readsPrec :: Int -> ReadS DeleteProfile
$creadsPrec :: Int -> ReadS DeleteProfile
Prelude.Read, Int -> DeleteProfile -> ShowS
[DeleteProfile] -> ShowS
DeleteProfile -> String
(Int -> DeleteProfile -> ShowS)
-> (DeleteProfile -> String)
-> ([DeleteProfile] -> ShowS)
-> Show DeleteProfile
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteProfile] -> ShowS
$cshowList :: [DeleteProfile] -> ShowS
show :: DeleteProfile -> String
$cshow :: DeleteProfile -> String
showsPrec :: Int -> DeleteProfile -> ShowS
$cshowsPrec :: Int -> DeleteProfile -> ShowS
Prelude.Show, (forall x. DeleteProfile -> Rep DeleteProfile x)
-> (forall x. Rep DeleteProfile x -> DeleteProfile)
-> Generic DeleteProfile
forall x. Rep DeleteProfile x -> DeleteProfile
forall x. DeleteProfile -> Rep DeleteProfile x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteProfile x -> DeleteProfile
$cfrom :: forall x. DeleteProfile -> Rep DeleteProfile x
Prelude.Generic)

-- |
-- Create a value of 'DeleteProfile' 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:
--
-- 'profileId', 'deleteProfile_profileId' - The unique identifier of a customer profile.
--
-- 'domainName', 'deleteProfile_domainName' - The unique name of the domain.
newDeleteProfile ::
  -- | 'profileId'
  Prelude.Text ->
  -- | 'domainName'
  Prelude.Text ->
  DeleteProfile
newDeleteProfile :: Text -> Text -> DeleteProfile
newDeleteProfile Text
pProfileId_ Text
pDomainName_ =
  DeleteProfile' :: Text -> Text -> DeleteProfile
DeleteProfile'
    { $sel:profileId:DeleteProfile' :: Text
profileId = Text
pProfileId_,
      $sel:domainName:DeleteProfile' :: Text
domainName = Text
pDomainName_
    }

-- | The unique identifier of a customer profile.
deleteProfile_profileId :: Lens.Lens' DeleteProfile Prelude.Text
deleteProfile_profileId :: (Text -> f Text) -> DeleteProfile -> f DeleteProfile
deleteProfile_profileId = (DeleteProfile -> Text)
-> (DeleteProfile -> Text -> DeleteProfile)
-> Lens DeleteProfile DeleteProfile Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteProfile' {Text
profileId :: Text
$sel:profileId:DeleteProfile' :: DeleteProfile -> Text
profileId} -> Text
profileId) (\s :: DeleteProfile
s@DeleteProfile' {} Text
a -> DeleteProfile
s {$sel:profileId:DeleteProfile' :: Text
profileId = Text
a} :: DeleteProfile)

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

instance Core.AWSRequest DeleteProfile where
  type
    AWSResponse DeleteProfile =
      DeleteProfileResponse
  request :: DeleteProfile -> Request DeleteProfile
request = Service -> DeleteProfile -> Request DeleteProfile
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteProfile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteProfile)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteProfile))
-> Logger
-> Service
-> Proxy DeleteProfile
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteProfile)))
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 Text -> Int -> DeleteProfileResponse
DeleteProfileResponse'
            (Maybe Text -> Int -> DeleteProfileResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteProfileResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Message")
            Either String (Int -> DeleteProfileResponse)
-> Either String Int -> Either String DeleteProfileResponse
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 DeleteProfile

instance Prelude.NFData DeleteProfile

instance Core.ToHeaders DeleteProfile where
  toHeaders :: DeleteProfile -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteProfile -> 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.ToJSON DeleteProfile where
  toJSON :: DeleteProfile -> Value
toJSON DeleteProfile' {Text
domainName :: Text
profileId :: Text
$sel:domainName:DeleteProfile' :: DeleteProfile -> Text
$sel:profileId:DeleteProfile' :: DeleteProfile -> 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
"ProfileId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
profileId)]
      )

instance Core.ToPath DeleteProfile where
  toPath :: DeleteProfile -> ByteString
toPath DeleteProfile' {Text
domainName :: Text
profileId :: Text
$sel:domainName:DeleteProfile' :: DeleteProfile -> Text
$sel:profileId:DeleteProfile' :: DeleteProfile -> 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,
        ByteString
"/profiles/delete"
      ]

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

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

-- |
-- Create a value of 'DeleteProfileResponse' 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:
--
-- 'message', 'deleteProfileResponse_message' - A message that indicates the delete request is done.
--
-- 'httpStatus', 'deleteProfileResponse_httpStatus' - The response's http status code.
newDeleteProfileResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteProfileResponse
newDeleteProfileResponse :: Int -> DeleteProfileResponse
newDeleteProfileResponse Int
pHttpStatus_ =
  DeleteProfileResponse' :: Maybe Text -> Int -> DeleteProfileResponse
DeleteProfileResponse'
    { $sel:message:DeleteProfileResponse' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteProfileResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

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

instance Prelude.NFData DeleteProfileResponse