{-# 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.DeleteContactMethod
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes a contact method.
--
-- A contact method is used to send you notifications about your Amazon
-- Lightsail resources. You can add one email address and one mobile phone
-- number contact method in each Amazon Web Services Region. However, SMS
-- text messaging is not supported in some Amazon Web Services Regions, and
-- SMS text messages cannot be sent to some countries\/regions. For more
-- information, see
-- <https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-notifications Notifications in Amazon Lightsail>.
module Amazonka.Lightsail.DeleteContactMethod
  ( -- * Creating a Request
    DeleteContactMethod (..),
    newDeleteContactMethod,

    -- * Request Lenses
    deleteContactMethod_protocol,

    -- * Destructuring the Response
    DeleteContactMethodResponse (..),
    newDeleteContactMethodResponse,

    -- * Response Lenses
    deleteContactMethodResponse_operations,
    deleteContactMethodResponse_httpStatus,
  )
where

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

-- | /See:/ 'newDeleteContactMethod' smart constructor.
data DeleteContactMethod = DeleteContactMethod'
  { -- | The protocol that will be deleted, such as @Email@ or @SMS@ (text
    -- messaging).
    --
    -- To delete an @Email@ and an @SMS@ contact method if you added both, you
    -- must run separate @DeleteContactMethod@ actions to delete each protocol.
    DeleteContactMethod -> ContactProtocol
protocol :: ContactProtocol
  }
  deriving (DeleteContactMethod -> DeleteContactMethod -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteContactMethod -> DeleteContactMethod -> Bool
$c/= :: DeleteContactMethod -> DeleteContactMethod -> Bool
== :: DeleteContactMethod -> DeleteContactMethod -> Bool
$c== :: DeleteContactMethod -> DeleteContactMethod -> Bool
Prelude.Eq, ReadPrec [DeleteContactMethod]
ReadPrec DeleteContactMethod
Int -> ReadS DeleteContactMethod
ReadS [DeleteContactMethod]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteContactMethod]
$creadListPrec :: ReadPrec [DeleteContactMethod]
readPrec :: ReadPrec DeleteContactMethod
$creadPrec :: ReadPrec DeleteContactMethod
readList :: ReadS [DeleteContactMethod]
$creadList :: ReadS [DeleteContactMethod]
readsPrec :: Int -> ReadS DeleteContactMethod
$creadsPrec :: Int -> ReadS DeleteContactMethod
Prelude.Read, Int -> DeleteContactMethod -> ShowS
[DeleteContactMethod] -> ShowS
DeleteContactMethod -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteContactMethod] -> ShowS
$cshowList :: [DeleteContactMethod] -> ShowS
show :: DeleteContactMethod -> String
$cshow :: DeleteContactMethod -> String
showsPrec :: Int -> DeleteContactMethod -> ShowS
$cshowsPrec :: Int -> DeleteContactMethod -> ShowS
Prelude.Show, forall x. Rep DeleteContactMethod x -> DeleteContactMethod
forall x. DeleteContactMethod -> Rep DeleteContactMethod x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteContactMethod x -> DeleteContactMethod
$cfrom :: forall x. DeleteContactMethod -> Rep DeleteContactMethod x
Prelude.Generic)

-- |
-- Create a value of 'DeleteContactMethod' 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:
--
-- 'protocol', 'deleteContactMethod_protocol' - The protocol that will be deleted, such as @Email@ or @SMS@ (text
-- messaging).
--
-- To delete an @Email@ and an @SMS@ contact method if you added both, you
-- must run separate @DeleteContactMethod@ actions to delete each protocol.
newDeleteContactMethod ::
  -- | 'protocol'
  ContactProtocol ->
  DeleteContactMethod
newDeleteContactMethod :: ContactProtocol -> DeleteContactMethod
newDeleteContactMethod ContactProtocol
pProtocol_ =
  DeleteContactMethod' {$sel:protocol:DeleteContactMethod' :: ContactProtocol
protocol = ContactProtocol
pProtocol_}

-- | The protocol that will be deleted, such as @Email@ or @SMS@ (text
-- messaging).
--
-- To delete an @Email@ and an @SMS@ contact method if you added both, you
-- must run separate @DeleteContactMethod@ actions to delete each protocol.
deleteContactMethod_protocol :: Lens.Lens' DeleteContactMethod ContactProtocol
deleteContactMethod_protocol :: Lens' DeleteContactMethod ContactProtocol
deleteContactMethod_protocol = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContactMethod' {ContactProtocol
protocol :: ContactProtocol
$sel:protocol:DeleteContactMethod' :: DeleteContactMethod -> ContactProtocol
protocol} -> ContactProtocol
protocol) (\s :: DeleteContactMethod
s@DeleteContactMethod' {} ContactProtocol
a -> DeleteContactMethod
s {$sel:protocol:DeleteContactMethod' :: ContactProtocol
protocol = ContactProtocol
a} :: DeleteContactMethod)

instance Core.AWSRequest DeleteContactMethod where
  type
    AWSResponse DeleteContactMethod =
      DeleteContactMethodResponse
  request :: (Service -> Service)
-> DeleteContactMethod -> Request DeleteContactMethod
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteContactMethod
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteContactMethod)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Operation] -> Int -> DeleteContactMethodResponse
DeleteContactMethodResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"operations" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DeleteContactMethod where
  hashWithSalt :: Int -> DeleteContactMethod -> Int
hashWithSalt Int
_salt DeleteContactMethod' {ContactProtocol
protocol :: ContactProtocol
$sel:protocol:DeleteContactMethod' :: DeleteContactMethod -> ContactProtocol
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ContactProtocol
protocol

instance Prelude.NFData DeleteContactMethod where
  rnf :: DeleteContactMethod -> ()
rnf DeleteContactMethod' {ContactProtocol
protocol :: ContactProtocol
$sel:protocol:DeleteContactMethod' :: DeleteContactMethod -> ContactProtocol
..} = forall a. NFData a => a -> ()
Prelude.rnf ContactProtocol
protocol

instance Data.ToHeaders DeleteContactMethod where
  toHeaders :: DeleteContactMethod -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"Lightsail_20161128.DeleteContactMethod" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON DeleteContactMethod where
  toJSON :: DeleteContactMethod -> Value
toJSON DeleteContactMethod' {ContactProtocol
protocol :: ContactProtocol
$sel:protocol:DeleteContactMethod' :: DeleteContactMethod -> ContactProtocol
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"protocol" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= ContactProtocol
protocol)]
      )

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

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

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

-- |
-- Create a value of 'DeleteContactMethodResponse' 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:
--
-- 'operations', 'deleteContactMethodResponse_operations' - 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', 'deleteContactMethodResponse_httpStatus' - The response's http status code.
newDeleteContactMethodResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteContactMethodResponse
newDeleteContactMethodResponse :: Int -> DeleteContactMethodResponse
newDeleteContactMethodResponse Int
pHttpStatus_ =
  DeleteContactMethodResponse'
    { $sel:operations:DeleteContactMethodResponse' :: Maybe [Operation]
operations =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteContactMethodResponse' :: 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.
deleteContactMethodResponse_operations :: Lens.Lens' DeleteContactMethodResponse (Prelude.Maybe [Operation])
deleteContactMethodResponse_operations :: Lens' DeleteContactMethodResponse (Maybe [Operation])
deleteContactMethodResponse_operations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteContactMethodResponse' {Maybe [Operation]
operations :: Maybe [Operation]
$sel:operations:DeleteContactMethodResponse' :: DeleteContactMethodResponse -> Maybe [Operation]
operations} -> Maybe [Operation]
operations) (\s :: DeleteContactMethodResponse
s@DeleteContactMethodResponse' {} Maybe [Operation]
a -> DeleteContactMethodResponse
s {$sel:operations:DeleteContactMethodResponse' :: Maybe [Operation]
operations = Maybe [Operation]
a} :: DeleteContactMethodResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData DeleteContactMethodResponse where
  rnf :: DeleteContactMethodResponse -> ()
rnf DeleteContactMethodResponse' {Int
Maybe [Operation]
httpStatus :: Int
operations :: Maybe [Operation]
$sel:httpStatus:DeleteContactMethodResponse' :: DeleteContactMethodResponse -> Int
$sel:operations:DeleteContactMethodResponse' :: DeleteContactMethodResponse -> Maybe [Operation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [Operation]
operations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus