{-# 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.Lightsail.DeleteDomainEntry
-- 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 entry.
--
-- The @delete domain entry@ operation supports tag-based access control
-- via resource tags applied to the resource identified by @domain name@.
-- For more information, see the
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-controlling-access-using-tags Amazon Lightsail Developer Guide>.
module Amazonka.Lightsail.DeleteDomainEntry
  ( -- * Creating a Request
    DeleteDomainEntry (..),
    newDeleteDomainEntry,

    -- * Request Lenses
    deleteDomainEntry_domainName,
    deleteDomainEntry_domainEntry,

    -- * Destructuring the Response
    DeleteDomainEntryResponse (..),
    newDeleteDomainEntryResponse,

    -- * Response Lenses
    deleteDomainEntryResponse_operation,
    deleteDomainEntryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Lightsail.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteDomainEntry' smart constructor.
data DeleteDomainEntry = DeleteDomainEntry'
  { -- | The name of the domain entry to delete.
    DeleteDomainEntry -> Text
domainName :: Prelude.Text,
    -- | An array of key-value pairs containing information about your domain
    -- entries.
    DeleteDomainEntry -> DomainEntry
domainEntry :: DomainEntry
  }
  deriving (DeleteDomainEntry -> DeleteDomainEntry -> Bool
(DeleteDomainEntry -> DeleteDomainEntry -> Bool)
-> (DeleteDomainEntry -> DeleteDomainEntry -> Bool)
-> Eq DeleteDomainEntry
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDomainEntry -> DeleteDomainEntry -> Bool
$c/= :: DeleteDomainEntry -> DeleteDomainEntry -> Bool
== :: DeleteDomainEntry -> DeleteDomainEntry -> Bool
$c== :: DeleteDomainEntry -> DeleteDomainEntry -> Bool
Prelude.Eq, ReadPrec [DeleteDomainEntry]
ReadPrec DeleteDomainEntry
Int -> ReadS DeleteDomainEntry
ReadS [DeleteDomainEntry]
(Int -> ReadS DeleteDomainEntry)
-> ReadS [DeleteDomainEntry]
-> ReadPrec DeleteDomainEntry
-> ReadPrec [DeleteDomainEntry]
-> Read DeleteDomainEntry
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDomainEntry]
$creadListPrec :: ReadPrec [DeleteDomainEntry]
readPrec :: ReadPrec DeleteDomainEntry
$creadPrec :: ReadPrec DeleteDomainEntry
readList :: ReadS [DeleteDomainEntry]
$creadList :: ReadS [DeleteDomainEntry]
readsPrec :: Int -> ReadS DeleteDomainEntry
$creadsPrec :: Int -> ReadS DeleteDomainEntry
Prelude.Read, Int -> DeleteDomainEntry -> ShowS
[DeleteDomainEntry] -> ShowS
DeleteDomainEntry -> String
(Int -> DeleteDomainEntry -> ShowS)
-> (DeleteDomainEntry -> String)
-> ([DeleteDomainEntry] -> ShowS)
-> Show DeleteDomainEntry
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDomainEntry] -> ShowS
$cshowList :: [DeleteDomainEntry] -> ShowS
show :: DeleteDomainEntry -> String
$cshow :: DeleteDomainEntry -> String
showsPrec :: Int -> DeleteDomainEntry -> ShowS
$cshowsPrec :: Int -> DeleteDomainEntry -> ShowS
Prelude.Show, (forall x. DeleteDomainEntry -> Rep DeleteDomainEntry x)
-> (forall x. Rep DeleteDomainEntry x -> DeleteDomainEntry)
-> Generic DeleteDomainEntry
forall x. Rep DeleteDomainEntry x -> DeleteDomainEntry
forall x. DeleteDomainEntry -> Rep DeleteDomainEntry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteDomainEntry x -> DeleteDomainEntry
$cfrom :: forall x. DeleteDomainEntry -> Rep DeleteDomainEntry x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDomainEntry' 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', 'deleteDomainEntry_domainName' - The name of the domain entry to delete.
--
-- 'domainEntry', 'deleteDomainEntry_domainEntry' - An array of key-value pairs containing information about your domain
-- entries.
newDeleteDomainEntry ::
  -- | 'domainName'
  Prelude.Text ->
  -- | 'domainEntry'
  DomainEntry ->
  DeleteDomainEntry
newDeleteDomainEntry :: Text -> DomainEntry -> DeleteDomainEntry
newDeleteDomainEntry Text
pDomainName_ DomainEntry
pDomainEntry_ =
  DeleteDomainEntry' :: Text -> DomainEntry -> DeleteDomainEntry
DeleteDomainEntry'
    { $sel:domainName:DeleteDomainEntry' :: Text
domainName = Text
pDomainName_,
      $sel:domainEntry:DeleteDomainEntry' :: DomainEntry
domainEntry = DomainEntry
pDomainEntry_
    }

-- | The name of the domain entry to delete.
deleteDomainEntry_domainName :: Lens.Lens' DeleteDomainEntry Prelude.Text
deleteDomainEntry_domainName :: (Text -> f Text) -> DeleteDomainEntry -> f DeleteDomainEntry
deleteDomainEntry_domainName = (DeleteDomainEntry -> Text)
-> (DeleteDomainEntry -> Text -> DeleteDomainEntry)
-> Lens DeleteDomainEntry DeleteDomainEntry Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomainEntry' {Text
domainName :: Text
$sel:domainName:DeleteDomainEntry' :: DeleteDomainEntry -> Text
domainName} -> Text
domainName) (\s :: DeleteDomainEntry
s@DeleteDomainEntry' {} Text
a -> DeleteDomainEntry
s {$sel:domainName:DeleteDomainEntry' :: Text
domainName = Text
a} :: DeleteDomainEntry)

-- | An array of key-value pairs containing information about your domain
-- entries.
deleteDomainEntry_domainEntry :: Lens.Lens' DeleteDomainEntry DomainEntry
deleteDomainEntry_domainEntry :: (DomainEntry -> f DomainEntry)
-> DeleteDomainEntry -> f DeleteDomainEntry
deleteDomainEntry_domainEntry = (DeleteDomainEntry -> DomainEntry)
-> (DeleteDomainEntry -> DomainEntry -> DeleteDomainEntry)
-> Lens DeleteDomainEntry DeleteDomainEntry DomainEntry DomainEntry
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomainEntry' {DomainEntry
domainEntry :: DomainEntry
$sel:domainEntry:DeleteDomainEntry' :: DeleteDomainEntry -> DomainEntry
domainEntry} -> DomainEntry
domainEntry) (\s :: DeleteDomainEntry
s@DeleteDomainEntry' {} DomainEntry
a -> DeleteDomainEntry
s {$sel:domainEntry:DeleteDomainEntry' :: DomainEntry
domainEntry = DomainEntry
a} :: DeleteDomainEntry)

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

instance Prelude.NFData DeleteDomainEntry

instance Core.ToHeaders DeleteDomainEntry where
  toHeaders :: DeleteDomainEntry -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteDomainEntry -> 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
"Lightsail_20161128.DeleteDomainEntry" ::
                          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 DeleteDomainEntry where
  toJSON :: DeleteDomainEntry -> Value
toJSON DeleteDomainEntry' {Text
DomainEntry
domainEntry :: DomainEntry
domainName :: Text
$sel:domainEntry:DeleteDomainEntry' :: DeleteDomainEntry -> DomainEntry
$sel:domainName:DeleteDomainEntry' :: DeleteDomainEntry -> 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
"domainName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
domainName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"domainEntry" Text -> DomainEntry -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= DomainEntry
domainEntry)
          ]
      )

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

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

-- | /See:/ 'newDeleteDomainEntryResponse' smart constructor.
data DeleteDomainEntryResponse = DeleteDomainEntryResponse'
  { -- | An array of objects that describe the result of the action, such as the
    -- status of the request, the timestamp of the request, and the resources
    -- affected by the request.
    DeleteDomainEntryResponse -> Maybe Operation
operation :: Prelude.Maybe Operation,
    -- | The response's http status code.
    DeleteDomainEntryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool
(DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool)
-> (DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool)
-> Eq DeleteDomainEntryResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool
$c/= :: DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool
== :: DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool
$c== :: DeleteDomainEntryResponse -> DeleteDomainEntryResponse -> Bool
Prelude.Eq, ReadPrec [DeleteDomainEntryResponse]
ReadPrec DeleteDomainEntryResponse
Int -> ReadS DeleteDomainEntryResponse
ReadS [DeleteDomainEntryResponse]
(Int -> ReadS DeleteDomainEntryResponse)
-> ReadS [DeleteDomainEntryResponse]
-> ReadPrec DeleteDomainEntryResponse
-> ReadPrec [DeleteDomainEntryResponse]
-> Read DeleteDomainEntryResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteDomainEntryResponse]
$creadListPrec :: ReadPrec [DeleteDomainEntryResponse]
readPrec :: ReadPrec DeleteDomainEntryResponse
$creadPrec :: ReadPrec DeleteDomainEntryResponse
readList :: ReadS [DeleteDomainEntryResponse]
$creadList :: ReadS [DeleteDomainEntryResponse]
readsPrec :: Int -> ReadS DeleteDomainEntryResponse
$creadsPrec :: Int -> ReadS DeleteDomainEntryResponse
Prelude.Read, Int -> DeleteDomainEntryResponse -> ShowS
[DeleteDomainEntryResponse] -> ShowS
DeleteDomainEntryResponse -> String
(Int -> DeleteDomainEntryResponse -> ShowS)
-> (DeleteDomainEntryResponse -> String)
-> ([DeleteDomainEntryResponse] -> ShowS)
-> Show DeleteDomainEntryResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteDomainEntryResponse] -> ShowS
$cshowList :: [DeleteDomainEntryResponse] -> ShowS
show :: DeleteDomainEntryResponse -> String
$cshow :: DeleteDomainEntryResponse -> String
showsPrec :: Int -> DeleteDomainEntryResponse -> ShowS
$cshowsPrec :: Int -> DeleteDomainEntryResponse -> ShowS
Prelude.Show, (forall x.
 DeleteDomainEntryResponse -> Rep DeleteDomainEntryResponse x)
-> (forall x.
    Rep DeleteDomainEntryResponse x -> DeleteDomainEntryResponse)
-> Generic DeleteDomainEntryResponse
forall x.
Rep DeleteDomainEntryResponse x -> DeleteDomainEntryResponse
forall x.
DeleteDomainEntryResponse -> Rep DeleteDomainEntryResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteDomainEntryResponse x -> DeleteDomainEntryResponse
$cfrom :: forall x.
DeleteDomainEntryResponse -> Rep DeleteDomainEntryResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteDomainEntryResponse' 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:
--
-- 'operation', 'deleteDomainEntryResponse_operation' - An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
--
-- 'httpStatus', 'deleteDomainEntryResponse_httpStatus' - The response's http status code.
newDeleteDomainEntryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteDomainEntryResponse
newDeleteDomainEntryResponse :: Int -> DeleteDomainEntryResponse
newDeleteDomainEntryResponse Int
pHttpStatus_ =
  DeleteDomainEntryResponse' :: Maybe Operation -> Int -> DeleteDomainEntryResponse
DeleteDomainEntryResponse'
    { $sel:operation:DeleteDomainEntryResponse' :: Maybe Operation
operation =
        Maybe Operation
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteDomainEntryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An array of objects that describe the result of the action, such as the
-- status of the request, the timestamp of the request, and the resources
-- affected by the request.
deleteDomainEntryResponse_operation :: Lens.Lens' DeleteDomainEntryResponse (Prelude.Maybe Operation)
deleteDomainEntryResponse_operation :: (Maybe Operation -> f (Maybe Operation))
-> DeleteDomainEntryResponse -> f DeleteDomainEntryResponse
deleteDomainEntryResponse_operation = (DeleteDomainEntryResponse -> Maybe Operation)
-> (DeleteDomainEntryResponse
    -> Maybe Operation -> DeleteDomainEntryResponse)
-> Lens
     DeleteDomainEntryResponse
     DeleteDomainEntryResponse
     (Maybe Operation)
     (Maybe Operation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteDomainEntryResponse' {Maybe Operation
operation :: Maybe Operation
$sel:operation:DeleteDomainEntryResponse' :: DeleteDomainEntryResponse -> Maybe Operation
operation} -> Maybe Operation
operation) (\s :: DeleteDomainEntryResponse
s@DeleteDomainEntryResponse' {} Maybe Operation
a -> DeleteDomainEntryResponse
s {$sel:operation:DeleteDomainEntryResponse' :: Maybe Operation
operation = Maybe Operation
a} :: DeleteDomainEntryResponse)

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

instance Prelude.NFData DeleteDomainEntryResponse