{-# 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.Route53RecoveryControlConfig.UpdateControlPanel
-- 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 control panel. The only update you can make to a control panel
-- is to change the name of the control panel.
module Amazonka.Route53RecoveryControlConfig.UpdateControlPanel
  ( -- * Creating a Request
    UpdateControlPanel (..),
    newUpdateControlPanel,

    -- * Request Lenses
    updateControlPanel_controlPanelArn,
    updateControlPanel_controlPanelName,

    -- * Destructuring the Response
    UpdateControlPanelResponse (..),
    newUpdateControlPanelResponse,

    -- * Response Lenses
    updateControlPanelResponse_controlPanel,
    updateControlPanelResponse_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.Route53RecoveryControlConfig.Types

-- | The details of the control panel that you\'re updating.
--
-- /See:/ 'newUpdateControlPanel' smart constructor.
data UpdateControlPanel = UpdateControlPanel'
  { -- | The Amazon Resource Name (ARN) of the control panel.
    UpdateControlPanel -> Text
controlPanelArn :: Prelude.Text,
    -- | The name of the control panel.
    UpdateControlPanel -> Text
controlPanelName :: Prelude.Text
  }
  deriving (UpdateControlPanel -> UpdateControlPanel -> Bool
(UpdateControlPanel -> UpdateControlPanel -> Bool)
-> (UpdateControlPanel -> UpdateControlPanel -> Bool)
-> Eq UpdateControlPanel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateControlPanel -> UpdateControlPanel -> Bool
$c/= :: UpdateControlPanel -> UpdateControlPanel -> Bool
== :: UpdateControlPanel -> UpdateControlPanel -> Bool
$c== :: UpdateControlPanel -> UpdateControlPanel -> Bool
Prelude.Eq, ReadPrec [UpdateControlPanel]
ReadPrec UpdateControlPanel
Int -> ReadS UpdateControlPanel
ReadS [UpdateControlPanel]
(Int -> ReadS UpdateControlPanel)
-> ReadS [UpdateControlPanel]
-> ReadPrec UpdateControlPanel
-> ReadPrec [UpdateControlPanel]
-> Read UpdateControlPanel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateControlPanel]
$creadListPrec :: ReadPrec [UpdateControlPanel]
readPrec :: ReadPrec UpdateControlPanel
$creadPrec :: ReadPrec UpdateControlPanel
readList :: ReadS [UpdateControlPanel]
$creadList :: ReadS [UpdateControlPanel]
readsPrec :: Int -> ReadS UpdateControlPanel
$creadsPrec :: Int -> ReadS UpdateControlPanel
Prelude.Read, Int -> UpdateControlPanel -> ShowS
[UpdateControlPanel] -> ShowS
UpdateControlPanel -> String
(Int -> UpdateControlPanel -> ShowS)
-> (UpdateControlPanel -> String)
-> ([UpdateControlPanel] -> ShowS)
-> Show UpdateControlPanel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateControlPanel] -> ShowS
$cshowList :: [UpdateControlPanel] -> ShowS
show :: UpdateControlPanel -> String
$cshow :: UpdateControlPanel -> String
showsPrec :: Int -> UpdateControlPanel -> ShowS
$cshowsPrec :: Int -> UpdateControlPanel -> ShowS
Prelude.Show, (forall x. UpdateControlPanel -> Rep UpdateControlPanel x)
-> (forall x. Rep UpdateControlPanel x -> UpdateControlPanel)
-> Generic UpdateControlPanel
forall x. Rep UpdateControlPanel x -> UpdateControlPanel
forall x. UpdateControlPanel -> Rep UpdateControlPanel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateControlPanel x -> UpdateControlPanel
$cfrom :: forall x. UpdateControlPanel -> Rep UpdateControlPanel x
Prelude.Generic)

-- |
-- Create a value of 'UpdateControlPanel' 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:
--
-- 'controlPanelArn', 'updateControlPanel_controlPanelArn' - The Amazon Resource Name (ARN) of the control panel.
--
-- 'controlPanelName', 'updateControlPanel_controlPanelName' - The name of the control panel.
newUpdateControlPanel ::
  -- | 'controlPanelArn'
  Prelude.Text ->
  -- | 'controlPanelName'
  Prelude.Text ->
  UpdateControlPanel
newUpdateControlPanel :: Text -> Text -> UpdateControlPanel
newUpdateControlPanel
  Text
pControlPanelArn_
  Text
pControlPanelName_ =
    UpdateControlPanel' :: Text -> Text -> UpdateControlPanel
UpdateControlPanel'
      { $sel:controlPanelArn:UpdateControlPanel' :: Text
controlPanelArn =
          Text
pControlPanelArn_,
        $sel:controlPanelName:UpdateControlPanel' :: Text
controlPanelName = Text
pControlPanelName_
      }

-- | The Amazon Resource Name (ARN) of the control panel.
updateControlPanel_controlPanelArn :: Lens.Lens' UpdateControlPanel Prelude.Text
updateControlPanel_controlPanelArn :: (Text -> f Text) -> UpdateControlPanel -> f UpdateControlPanel
updateControlPanel_controlPanelArn = (UpdateControlPanel -> Text)
-> (UpdateControlPanel -> Text -> UpdateControlPanel)
-> Lens UpdateControlPanel UpdateControlPanel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateControlPanel' {Text
controlPanelArn :: Text
$sel:controlPanelArn:UpdateControlPanel' :: UpdateControlPanel -> Text
controlPanelArn} -> Text
controlPanelArn) (\s :: UpdateControlPanel
s@UpdateControlPanel' {} Text
a -> UpdateControlPanel
s {$sel:controlPanelArn:UpdateControlPanel' :: Text
controlPanelArn = Text
a} :: UpdateControlPanel)

-- | The name of the control panel.
updateControlPanel_controlPanelName :: Lens.Lens' UpdateControlPanel Prelude.Text
updateControlPanel_controlPanelName :: (Text -> f Text) -> UpdateControlPanel -> f UpdateControlPanel
updateControlPanel_controlPanelName = (UpdateControlPanel -> Text)
-> (UpdateControlPanel -> Text -> UpdateControlPanel)
-> Lens UpdateControlPanel UpdateControlPanel Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateControlPanel' {Text
controlPanelName :: Text
$sel:controlPanelName:UpdateControlPanel' :: UpdateControlPanel -> Text
controlPanelName} -> Text
controlPanelName) (\s :: UpdateControlPanel
s@UpdateControlPanel' {} Text
a -> UpdateControlPanel
s {$sel:controlPanelName:UpdateControlPanel' :: Text
controlPanelName = Text
a} :: UpdateControlPanel)

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

instance Prelude.NFData UpdateControlPanel

instance Core.ToHeaders UpdateControlPanel where
  toHeaders :: UpdateControlPanel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateControlPanel -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ 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 UpdateControlPanel where
  toJSON :: UpdateControlPanel -> Value
toJSON UpdateControlPanel' {Text
controlPanelName :: Text
controlPanelArn :: Text
$sel:controlPanelName:UpdateControlPanel' :: UpdateControlPanel -> Text
$sel:controlPanelArn:UpdateControlPanel' :: UpdateControlPanel -> 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
"ControlPanelArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
controlPanelArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ControlPanelName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
controlPanelName)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateControlPanelResponse' 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:
--
-- 'controlPanel', 'updateControlPanelResponse_controlPanel' - The control panel to update.
--
-- 'httpStatus', 'updateControlPanelResponse_httpStatus' - The response's http status code.
newUpdateControlPanelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateControlPanelResponse
newUpdateControlPanelResponse :: Int -> UpdateControlPanelResponse
newUpdateControlPanelResponse Int
pHttpStatus_ =
  UpdateControlPanelResponse' :: Maybe ControlPanel -> Int -> UpdateControlPanelResponse
UpdateControlPanelResponse'
    { $sel:controlPanel:UpdateControlPanelResponse' :: Maybe ControlPanel
controlPanel =
        Maybe ControlPanel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateControlPanelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The control panel to update.
updateControlPanelResponse_controlPanel :: Lens.Lens' UpdateControlPanelResponse (Prelude.Maybe ControlPanel)
updateControlPanelResponse_controlPanel :: (Maybe ControlPanel -> f (Maybe ControlPanel))
-> UpdateControlPanelResponse -> f UpdateControlPanelResponse
updateControlPanelResponse_controlPanel = (UpdateControlPanelResponse -> Maybe ControlPanel)
-> (UpdateControlPanelResponse
    -> Maybe ControlPanel -> UpdateControlPanelResponse)
-> Lens
     UpdateControlPanelResponse
     UpdateControlPanelResponse
     (Maybe ControlPanel)
     (Maybe ControlPanel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateControlPanelResponse' {Maybe ControlPanel
controlPanel :: Maybe ControlPanel
$sel:controlPanel:UpdateControlPanelResponse' :: UpdateControlPanelResponse -> Maybe ControlPanel
controlPanel} -> Maybe ControlPanel
controlPanel) (\s :: UpdateControlPanelResponse
s@UpdateControlPanelResponse' {} Maybe ControlPanel
a -> UpdateControlPanelResponse
s {$sel:controlPanel:UpdateControlPanelResponse' :: Maybe ControlPanel
controlPanel = Maybe ControlPanel
a} :: UpdateControlPanelResponse)

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

instance Prelude.NFData UpdateControlPanelResponse