{-# 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-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 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 AWS Region. However, SMS text messaging is
-- not supported in some AWS 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.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:/ '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
(DeleteContactMethod -> DeleteContactMethod -> Bool)
-> (DeleteContactMethod -> DeleteContactMethod -> Bool)
-> Eq DeleteContactMethod
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]
(Int -> ReadS DeleteContactMethod)
-> ReadS [DeleteContactMethod]
-> ReadPrec DeleteContactMethod
-> ReadPrec [DeleteContactMethod]
-> Read 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
(Int -> DeleteContactMethod -> ShowS)
-> (DeleteContactMethod -> String)
-> ([DeleteContactMethod] -> ShowS)
-> Show DeleteContactMethod
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. DeleteContactMethod -> Rep DeleteContactMethod x)
-> (forall x. Rep DeleteContactMethod x -> DeleteContactMethod)
-> Generic DeleteContactMethod
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' :: ContactProtocol -> DeleteContactMethod
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 :: (ContactProtocol -> f ContactProtocol)
-> DeleteContactMethod -> f DeleteContactMethod
deleteContactMethod_protocol = (DeleteContactMethod -> ContactProtocol)
-> (DeleteContactMethod -> ContactProtocol -> DeleteContactMethod)
-> Lens
     DeleteContactMethod
     DeleteContactMethod
     ContactProtocol
     ContactProtocol
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 :: DeleteContactMethod -> Request DeleteContactMethod
request = Service -> DeleteContactMethod -> Request DeleteContactMethod
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteContactMethod
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteContactMethod)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteContactMethod))
-> Logger
-> Service
-> Proxy DeleteContactMethod
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteContactMethod)))
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 -> DeleteContactMethodResponse
DeleteContactMethodResponse'
            (Maybe [Operation] -> Int -> DeleteContactMethodResponse)
-> Either String (Maybe [Operation])
-> Either String (Int -> DeleteContactMethodResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe (Maybe [Operation]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"operations" Either String (Maybe (Maybe [Operation]))
-> Maybe [Operation] -> Either String (Maybe [Operation])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Operation]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> DeleteContactMethodResponse)
-> Either String Int -> Either String DeleteContactMethodResponse
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 DeleteContactMethod

instance Prelude.NFData DeleteContactMethod

instance Core.ToHeaders DeleteContactMethod where
  toHeaders :: DeleteContactMethod -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteContactMethod -> 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.DeleteContactMethod" ::
                          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 DeleteContactMethod where
  toJSON :: DeleteContactMethod -> Value
toJSON DeleteContactMethod' {ContactProtocol
protocol :: ContactProtocol
$sel:protocol:DeleteContactMethod' :: DeleteContactMethod -> ContactProtocol
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Key
"protocol" Key -> ContactProtocol -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..= ContactProtocol
protocol)]
      )

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

instance Core.ToQuery DeleteContactMethod where
  toQuery :: DeleteContactMethod -> QueryString
toQuery = QueryString -> DeleteContactMethod -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteContactMethodResponse
 -> DeleteContactMethodResponse -> Bool)
-> (DeleteContactMethodResponse
    -> DeleteContactMethodResponse -> Bool)
-> Eq DeleteContactMethodResponse
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]
(Int -> ReadS DeleteContactMethodResponse)
-> ReadS [DeleteContactMethodResponse]
-> ReadPrec DeleteContactMethodResponse
-> ReadPrec [DeleteContactMethodResponse]
-> Read 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
(Int -> DeleteContactMethodResponse -> ShowS)
-> (DeleteContactMethodResponse -> String)
-> ([DeleteContactMethodResponse] -> ShowS)
-> Show DeleteContactMethodResponse
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.
 DeleteContactMethodResponse -> Rep DeleteContactMethodResponse x)
-> (forall x.
    Rep DeleteContactMethodResponse x -> DeleteContactMethodResponse)
-> Generic DeleteContactMethodResponse
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' :: Maybe [Operation] -> Int -> DeleteContactMethodResponse
DeleteContactMethodResponse'
    { $sel:operations:DeleteContactMethodResponse' :: Maybe [Operation]
operations =
        Maybe [Operation]
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 :: (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteContactMethodResponse -> f DeleteContactMethodResponse
deleteContactMethodResponse_operations = (DeleteContactMethodResponse -> Maybe [Operation])
-> (DeleteContactMethodResponse
    -> Maybe [Operation] -> DeleteContactMethodResponse)
-> Lens
     DeleteContactMethodResponse
     DeleteContactMethodResponse
     (Maybe [Operation])
     (Maybe [Operation])
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) ((Maybe [Operation] -> f (Maybe [Operation]))
 -> DeleteContactMethodResponse -> f DeleteContactMethodResponse)
-> ((Maybe [Operation] -> f (Maybe [Operation]))
    -> Maybe [Operation] -> f (Maybe [Operation]))
-> (Maybe [Operation] -> f (Maybe [Operation]))
-> DeleteContactMethodResponse
-> f DeleteContactMethodResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Operation] [Operation] [Operation] [Operation]
-> Iso
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
     (Maybe [Operation])
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 AnIso [Operation] [Operation] [Operation] [Operation]
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 :: (Int -> f Int)
-> DeleteContactMethodResponse -> f DeleteContactMethodResponse
deleteContactMethodResponse_httpStatus = (DeleteContactMethodResponse -> Int)
-> (DeleteContactMethodResponse
    -> Int -> DeleteContactMethodResponse)
-> Lens
     DeleteContactMethodResponse DeleteContactMethodResponse Int Int
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