{-# 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.SSMContacts.UpdateContactChannel
-- 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)
--
-- Updates a contact\'s contact channel.
module Amazonka.SSMContacts.UpdateContactChannel
  ( -- * Creating a Request
    UpdateContactChannel (..),
    newUpdateContactChannel,

    -- * Request Lenses
    updateContactChannel_name,
    updateContactChannel_deliveryAddress,
    updateContactChannel_contactChannelId,

    -- * Destructuring the Response
    UpdateContactChannelResponse (..),
    newUpdateContactChannelResponse,

    -- * Response Lenses
    updateContactChannelResponse_httpStatus,
  )
where

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
import Amazonka.SSMContacts.Types

-- | /See:/ 'newUpdateContactChannel' smart constructor.
data UpdateContactChannel = UpdateContactChannel'
  { -- | The name of the contact channel.
    UpdateContactChannel -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The details that Incident Manager uses when trying to engage the contact
    -- channel.
    UpdateContactChannel -> Maybe ContactChannelAddress
deliveryAddress :: Prelude.Maybe ContactChannelAddress,
    -- | The Amazon Resource Name (ARN) of the contact channel you want to
    -- update.
    UpdateContactChannel -> Text
contactChannelId :: Prelude.Text
  }
  deriving (UpdateContactChannel -> UpdateContactChannel -> Bool
(UpdateContactChannel -> UpdateContactChannel -> Bool)
-> (UpdateContactChannel -> UpdateContactChannel -> Bool)
-> Eq UpdateContactChannel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateContactChannel -> UpdateContactChannel -> Bool
$c/= :: UpdateContactChannel -> UpdateContactChannel -> Bool
== :: UpdateContactChannel -> UpdateContactChannel -> Bool
$c== :: UpdateContactChannel -> UpdateContactChannel -> Bool
Prelude.Eq, ReadPrec [UpdateContactChannel]
ReadPrec UpdateContactChannel
Int -> ReadS UpdateContactChannel
ReadS [UpdateContactChannel]
(Int -> ReadS UpdateContactChannel)
-> ReadS [UpdateContactChannel]
-> ReadPrec UpdateContactChannel
-> ReadPrec [UpdateContactChannel]
-> Read UpdateContactChannel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateContactChannel]
$creadListPrec :: ReadPrec [UpdateContactChannel]
readPrec :: ReadPrec UpdateContactChannel
$creadPrec :: ReadPrec UpdateContactChannel
readList :: ReadS [UpdateContactChannel]
$creadList :: ReadS [UpdateContactChannel]
readsPrec :: Int -> ReadS UpdateContactChannel
$creadsPrec :: Int -> ReadS UpdateContactChannel
Prelude.Read, Int -> UpdateContactChannel -> ShowS
[UpdateContactChannel] -> ShowS
UpdateContactChannel -> String
(Int -> UpdateContactChannel -> ShowS)
-> (UpdateContactChannel -> String)
-> ([UpdateContactChannel] -> ShowS)
-> Show UpdateContactChannel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateContactChannel] -> ShowS
$cshowList :: [UpdateContactChannel] -> ShowS
show :: UpdateContactChannel -> String
$cshow :: UpdateContactChannel -> String
showsPrec :: Int -> UpdateContactChannel -> ShowS
$cshowsPrec :: Int -> UpdateContactChannel -> ShowS
Prelude.Show, (forall x. UpdateContactChannel -> Rep UpdateContactChannel x)
-> (forall x. Rep UpdateContactChannel x -> UpdateContactChannel)
-> Generic UpdateContactChannel
forall x. Rep UpdateContactChannel x -> UpdateContactChannel
forall x. UpdateContactChannel -> Rep UpdateContactChannel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateContactChannel x -> UpdateContactChannel
$cfrom :: forall x. UpdateContactChannel -> Rep UpdateContactChannel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateContactChannel' 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:
--
-- 'name', 'updateContactChannel_name' - The name of the contact channel.
--
-- 'deliveryAddress', 'updateContactChannel_deliveryAddress' - The details that Incident Manager uses when trying to engage the contact
-- channel.
--
-- 'contactChannelId', 'updateContactChannel_contactChannelId' - The Amazon Resource Name (ARN) of the contact channel you want to
-- update.
newUpdateContactChannel ::
  -- | 'contactChannelId'
  Prelude.Text ->
  UpdateContactChannel
newUpdateContactChannel :: Text -> UpdateContactChannel
newUpdateContactChannel Text
pContactChannelId_ =
  UpdateContactChannel' :: Maybe Text
-> Maybe ContactChannelAddress -> Text -> UpdateContactChannel
UpdateContactChannel'
    { $sel:name:UpdateContactChannel' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deliveryAddress:UpdateContactChannel' :: Maybe ContactChannelAddress
deliveryAddress = Maybe ContactChannelAddress
forall a. Maybe a
Prelude.Nothing,
      $sel:contactChannelId:UpdateContactChannel' :: Text
contactChannelId = Text
pContactChannelId_
    }

-- | The name of the contact channel.
updateContactChannel_name :: Lens.Lens' UpdateContactChannel (Prelude.Maybe Prelude.Text)
updateContactChannel_name :: (Maybe Text -> f (Maybe Text))
-> UpdateContactChannel -> f UpdateContactChannel
updateContactChannel_name = (UpdateContactChannel -> Maybe Text)
-> (UpdateContactChannel -> Maybe Text -> UpdateContactChannel)
-> Lens
     UpdateContactChannel UpdateContactChannel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactChannel' {Maybe Text
name :: Maybe Text
$sel:name:UpdateContactChannel' :: UpdateContactChannel -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateContactChannel
s@UpdateContactChannel' {} Maybe Text
a -> UpdateContactChannel
s {$sel:name:UpdateContactChannel' :: Maybe Text
name = Maybe Text
a} :: UpdateContactChannel)

-- | The details that Incident Manager uses when trying to engage the contact
-- channel.
updateContactChannel_deliveryAddress :: Lens.Lens' UpdateContactChannel (Prelude.Maybe ContactChannelAddress)
updateContactChannel_deliveryAddress :: (Maybe ContactChannelAddress -> f (Maybe ContactChannelAddress))
-> UpdateContactChannel -> f UpdateContactChannel
updateContactChannel_deliveryAddress = (UpdateContactChannel -> Maybe ContactChannelAddress)
-> (UpdateContactChannel
    -> Maybe ContactChannelAddress -> UpdateContactChannel)
-> Lens
     UpdateContactChannel
     UpdateContactChannel
     (Maybe ContactChannelAddress)
     (Maybe ContactChannelAddress)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactChannel' {Maybe ContactChannelAddress
deliveryAddress :: Maybe ContactChannelAddress
$sel:deliveryAddress:UpdateContactChannel' :: UpdateContactChannel -> Maybe ContactChannelAddress
deliveryAddress} -> Maybe ContactChannelAddress
deliveryAddress) (\s :: UpdateContactChannel
s@UpdateContactChannel' {} Maybe ContactChannelAddress
a -> UpdateContactChannel
s {$sel:deliveryAddress:UpdateContactChannel' :: Maybe ContactChannelAddress
deliveryAddress = Maybe ContactChannelAddress
a} :: UpdateContactChannel)

-- | The Amazon Resource Name (ARN) of the contact channel you want to
-- update.
updateContactChannel_contactChannelId :: Lens.Lens' UpdateContactChannel Prelude.Text
updateContactChannel_contactChannelId :: (Text -> f Text) -> UpdateContactChannel -> f UpdateContactChannel
updateContactChannel_contactChannelId = (UpdateContactChannel -> Text)
-> (UpdateContactChannel -> Text -> UpdateContactChannel)
-> Lens UpdateContactChannel UpdateContactChannel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateContactChannel' {Text
contactChannelId :: Text
$sel:contactChannelId:UpdateContactChannel' :: UpdateContactChannel -> Text
contactChannelId} -> Text
contactChannelId) (\s :: UpdateContactChannel
s@UpdateContactChannel' {} Text
a -> UpdateContactChannel
s {$sel:contactChannelId:UpdateContactChannel' :: Text
contactChannelId = Text
a} :: UpdateContactChannel)

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

instance Prelude.NFData UpdateContactChannel

instance Core.ToHeaders UpdateContactChannel where
  toHeaders :: UpdateContactChannel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateContactChannel -> 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
"SSMContacts.UpdateContactChannel" ::
                          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 UpdateContactChannel where
  toJSON :: UpdateContactChannel -> Value
toJSON UpdateContactChannel' {Maybe Text
Maybe ContactChannelAddress
Text
contactChannelId :: Text
deliveryAddress :: Maybe ContactChannelAddress
name :: Maybe Text
$sel:contactChannelId:UpdateContactChannel' :: UpdateContactChannel -> Text
$sel:deliveryAddress:UpdateContactChannel' :: UpdateContactChannel -> Maybe ContactChannelAddress
$sel:name:UpdateContactChannel' :: UpdateContactChannel -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
name,
            (Text
"DeliveryAddress" Text -> ContactChannelAddress -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ContactChannelAddress -> Pair)
-> Maybe ContactChannelAddress -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ContactChannelAddress
deliveryAddress,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ContactChannelId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
contactChannelId)
          ]
      )

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

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

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

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

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

instance Prelude.NFData UpdateContactChannelResponse