{-# 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.CognitoIdentityProvider.DeleteUserPoolDomain
-- 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 domain for a user pool.
module Amazonka.CognitoIdentityProvider.DeleteUserPoolDomain
  ( -- * Creating a Request
    DeleteUserPoolDomain (..),
    newDeleteUserPoolDomain,

    -- * Request Lenses
    deleteUserPoolDomain_domain,
    deleteUserPoolDomain_userPoolId,

    -- * Destructuring the Response
    DeleteUserPoolDomainResponse (..),
    newDeleteUserPoolDomainResponse,

    -- * Response Lenses
    deleteUserPoolDomainResponse_httpStatus,
  )
where

import Amazonka.CognitoIdentityProvider.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:/ 'newDeleteUserPoolDomain' smart constructor.
data DeleteUserPoolDomain = DeleteUserPoolDomain'
  { -- | The domain string.
    DeleteUserPoolDomain -> Text
domain :: Prelude.Text,
    -- | The user pool ID.
    DeleteUserPoolDomain -> Text
userPoolId :: Prelude.Text
  }
  deriving (DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool
(DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool)
-> (DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool)
-> Eq DeleteUserPoolDomain
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool
$c/= :: DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool
== :: DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool
$c== :: DeleteUserPoolDomain -> DeleteUserPoolDomain -> Bool
Prelude.Eq, ReadPrec [DeleteUserPoolDomain]
ReadPrec DeleteUserPoolDomain
Int -> ReadS DeleteUserPoolDomain
ReadS [DeleteUserPoolDomain]
(Int -> ReadS DeleteUserPoolDomain)
-> ReadS [DeleteUserPoolDomain]
-> ReadPrec DeleteUserPoolDomain
-> ReadPrec [DeleteUserPoolDomain]
-> Read DeleteUserPoolDomain
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteUserPoolDomain]
$creadListPrec :: ReadPrec [DeleteUserPoolDomain]
readPrec :: ReadPrec DeleteUserPoolDomain
$creadPrec :: ReadPrec DeleteUserPoolDomain
readList :: ReadS [DeleteUserPoolDomain]
$creadList :: ReadS [DeleteUserPoolDomain]
readsPrec :: Int -> ReadS DeleteUserPoolDomain
$creadsPrec :: Int -> ReadS DeleteUserPoolDomain
Prelude.Read, Int -> DeleteUserPoolDomain -> ShowS
[DeleteUserPoolDomain] -> ShowS
DeleteUserPoolDomain -> String
(Int -> DeleteUserPoolDomain -> ShowS)
-> (DeleteUserPoolDomain -> String)
-> ([DeleteUserPoolDomain] -> ShowS)
-> Show DeleteUserPoolDomain
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteUserPoolDomain] -> ShowS
$cshowList :: [DeleteUserPoolDomain] -> ShowS
show :: DeleteUserPoolDomain -> String
$cshow :: DeleteUserPoolDomain -> String
showsPrec :: Int -> DeleteUserPoolDomain -> ShowS
$cshowsPrec :: Int -> DeleteUserPoolDomain -> ShowS
Prelude.Show, (forall x. DeleteUserPoolDomain -> Rep DeleteUserPoolDomain x)
-> (forall x. Rep DeleteUserPoolDomain x -> DeleteUserPoolDomain)
-> Generic DeleteUserPoolDomain
forall x. Rep DeleteUserPoolDomain x -> DeleteUserPoolDomain
forall x. DeleteUserPoolDomain -> Rep DeleteUserPoolDomain x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteUserPoolDomain x -> DeleteUserPoolDomain
$cfrom :: forall x. DeleteUserPoolDomain -> Rep DeleteUserPoolDomain x
Prelude.Generic)

-- |
-- Create a value of 'DeleteUserPoolDomain' 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:
--
-- 'domain', 'deleteUserPoolDomain_domain' - The domain string.
--
-- 'userPoolId', 'deleteUserPoolDomain_userPoolId' - The user pool ID.
newDeleteUserPoolDomain ::
  -- | 'domain'
  Prelude.Text ->
  -- | 'userPoolId'
  Prelude.Text ->
  DeleteUserPoolDomain
newDeleteUserPoolDomain :: Text -> Text -> DeleteUserPoolDomain
newDeleteUserPoolDomain Text
pDomain_ Text
pUserPoolId_ =
  DeleteUserPoolDomain' :: Text -> Text -> DeleteUserPoolDomain
DeleteUserPoolDomain'
    { $sel:domain:DeleteUserPoolDomain' :: Text
domain = Text
pDomain_,
      $sel:userPoolId:DeleteUserPoolDomain' :: Text
userPoolId = Text
pUserPoolId_
    }

-- | The domain string.
deleteUserPoolDomain_domain :: Lens.Lens' DeleteUserPoolDomain Prelude.Text
deleteUserPoolDomain_domain :: (Text -> f Text) -> DeleteUserPoolDomain -> f DeleteUserPoolDomain
deleteUserPoolDomain_domain = (DeleteUserPoolDomain -> Text)
-> (DeleteUserPoolDomain -> Text -> DeleteUserPoolDomain)
-> Lens DeleteUserPoolDomain DeleteUserPoolDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserPoolDomain' {Text
domain :: Text
$sel:domain:DeleteUserPoolDomain' :: DeleteUserPoolDomain -> Text
domain} -> Text
domain) (\s :: DeleteUserPoolDomain
s@DeleteUserPoolDomain' {} Text
a -> DeleteUserPoolDomain
s {$sel:domain:DeleteUserPoolDomain' :: Text
domain = Text
a} :: DeleteUserPoolDomain)

-- | The user pool ID.
deleteUserPoolDomain_userPoolId :: Lens.Lens' DeleteUserPoolDomain Prelude.Text
deleteUserPoolDomain_userPoolId :: (Text -> f Text) -> DeleteUserPoolDomain -> f DeleteUserPoolDomain
deleteUserPoolDomain_userPoolId = (DeleteUserPoolDomain -> Text)
-> (DeleteUserPoolDomain -> Text -> DeleteUserPoolDomain)
-> Lens DeleteUserPoolDomain DeleteUserPoolDomain Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteUserPoolDomain' {Text
userPoolId :: Text
$sel:userPoolId:DeleteUserPoolDomain' :: DeleteUserPoolDomain -> Text
userPoolId} -> Text
userPoolId) (\s :: DeleteUserPoolDomain
s@DeleteUserPoolDomain' {} Text
a -> DeleteUserPoolDomain
s {$sel:userPoolId:DeleteUserPoolDomain' :: Text
userPoolId = Text
a} :: DeleteUserPoolDomain)

instance Core.AWSRequest DeleteUserPoolDomain where
  type
    AWSResponse DeleteUserPoolDomain =
      DeleteUserPoolDomainResponse
  request :: DeleteUserPoolDomain -> Request DeleteUserPoolDomain
request = Service -> DeleteUserPoolDomain -> Request DeleteUserPoolDomain
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteUserPoolDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserPoolDomain)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeleteUserPoolDomain))
-> Logger
-> Service
-> Proxy DeleteUserPoolDomain
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteUserPoolDomain)))
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 -> DeleteUserPoolDomainResponse
DeleteUserPoolDomainResponse'
            (Int -> DeleteUserPoolDomainResponse)
-> Either String Int -> Either String DeleteUserPoolDomainResponse
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 DeleteUserPoolDomain

instance Prelude.NFData DeleteUserPoolDomain

instance Core.ToHeaders DeleteUserPoolDomain where
  toHeaders :: DeleteUserPoolDomain -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteUserPoolDomain -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AWSCognitoIdentityProviderService.DeleteUserPoolDomain" ::
                          Prelude.ByteString
                      ),
            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 DeleteUserPoolDomain where
  toJSON :: DeleteUserPoolDomain -> Value
toJSON DeleteUserPoolDomain' {Text
userPoolId :: Text
domain :: Text
$sel:userPoolId:DeleteUserPoolDomain' :: DeleteUserPoolDomain -> Text
$sel:domain:DeleteUserPoolDomain' :: DeleteUserPoolDomain -> 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
"Domain" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domain),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"UserPoolId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
userPoolId)
          ]
      )

instance Core.ToPath DeleteUserPoolDomain where
  toPath :: DeleteUserPoolDomain -> ByteString
toPath = ByteString -> DeleteUserPoolDomain -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

instance Prelude.NFData DeleteUserPoolDomainResponse