{-# 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.CreateControlPanel
-- 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)
--
-- Creates a new control panel. A control panel represents a group of
-- routing controls that can be changed together in a single transaction.
-- You can use a control panel to centrally view the operational status of
-- applications across your organization, and trigger multi-app failovers
-- in a single transaction, for example, to fail over an Availability Zone
-- or AWS Region.
module Amazonka.Route53RecoveryControlConfig.CreateControlPanel
  ( -- * Creating a Request
    CreateControlPanel (..),
    newCreateControlPanel,

    -- * Request Lenses
    createControlPanel_clientToken,
    createControlPanel_clusterArn,
    createControlPanel_controlPanelName,

    -- * Destructuring the Response
    CreateControlPanelResponse (..),
    newCreateControlPanelResponse,

    -- * Response Lenses
    createControlPanelResponse_controlPanel,
    createControlPanelResponse_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 creating.
--
-- /See:/ 'newCreateControlPanel' smart constructor.
data CreateControlPanel = CreateControlPanel'
  { -- | Unique client idempotency token.
    CreateControlPanel -> Maybe Text
clientToken :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the cluster for the control panel.
    CreateControlPanel -> Text
clusterArn :: Prelude.Text,
    -- | The name of the control panel.
    CreateControlPanel -> Text
controlPanelName :: Prelude.Text
  }
  deriving (CreateControlPanel -> CreateControlPanel -> Bool
(CreateControlPanel -> CreateControlPanel -> Bool)
-> (CreateControlPanel -> CreateControlPanel -> Bool)
-> Eq CreateControlPanel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateControlPanel -> CreateControlPanel -> Bool
$c/= :: CreateControlPanel -> CreateControlPanel -> Bool
== :: CreateControlPanel -> CreateControlPanel -> Bool
$c== :: CreateControlPanel -> CreateControlPanel -> Bool
Prelude.Eq, ReadPrec [CreateControlPanel]
ReadPrec CreateControlPanel
Int -> ReadS CreateControlPanel
ReadS [CreateControlPanel]
(Int -> ReadS CreateControlPanel)
-> ReadS [CreateControlPanel]
-> ReadPrec CreateControlPanel
-> ReadPrec [CreateControlPanel]
-> Read CreateControlPanel
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateControlPanel]
$creadListPrec :: ReadPrec [CreateControlPanel]
readPrec :: ReadPrec CreateControlPanel
$creadPrec :: ReadPrec CreateControlPanel
readList :: ReadS [CreateControlPanel]
$creadList :: ReadS [CreateControlPanel]
readsPrec :: Int -> ReadS CreateControlPanel
$creadsPrec :: Int -> ReadS CreateControlPanel
Prelude.Read, Int -> CreateControlPanel -> ShowS
[CreateControlPanel] -> ShowS
CreateControlPanel -> String
(Int -> CreateControlPanel -> ShowS)
-> (CreateControlPanel -> String)
-> ([CreateControlPanel] -> ShowS)
-> Show CreateControlPanel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateControlPanel] -> ShowS
$cshowList :: [CreateControlPanel] -> ShowS
show :: CreateControlPanel -> String
$cshow :: CreateControlPanel -> String
showsPrec :: Int -> CreateControlPanel -> ShowS
$cshowsPrec :: Int -> CreateControlPanel -> ShowS
Prelude.Show, (forall x. CreateControlPanel -> Rep CreateControlPanel x)
-> (forall x. Rep CreateControlPanel x -> CreateControlPanel)
-> Generic CreateControlPanel
forall x. Rep CreateControlPanel x -> CreateControlPanel
forall x. CreateControlPanel -> Rep CreateControlPanel x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateControlPanel x -> CreateControlPanel
$cfrom :: forall x. CreateControlPanel -> Rep CreateControlPanel x
Prelude.Generic)

-- |
-- Create a value of 'CreateControlPanel' 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:
--
-- 'clientToken', 'createControlPanel_clientToken' - Unique client idempotency token.
--
-- 'clusterArn', 'createControlPanel_clusterArn' - The Amazon Resource Name (ARN) of the cluster for the control panel.
--
-- 'controlPanelName', 'createControlPanel_controlPanelName' - The name of the control panel.
newCreateControlPanel ::
  -- | 'clusterArn'
  Prelude.Text ->
  -- | 'controlPanelName'
  Prelude.Text ->
  CreateControlPanel
newCreateControlPanel :: Text -> Text -> CreateControlPanel
newCreateControlPanel Text
pClusterArn_ Text
pControlPanelName_ =
  CreateControlPanel' :: Maybe Text -> Text -> Text -> CreateControlPanel
CreateControlPanel'
    { $sel:clientToken:CreateControlPanel' :: Maybe Text
clientToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterArn:CreateControlPanel' :: Text
clusterArn = Text
pClusterArn_,
      $sel:controlPanelName:CreateControlPanel' :: Text
controlPanelName = Text
pControlPanelName_
    }

-- | Unique client idempotency token.
createControlPanel_clientToken :: Lens.Lens' CreateControlPanel (Prelude.Maybe Prelude.Text)
createControlPanel_clientToken :: (Maybe Text -> f (Maybe Text))
-> CreateControlPanel -> f CreateControlPanel
createControlPanel_clientToken = (CreateControlPanel -> Maybe Text)
-> (CreateControlPanel -> Maybe Text -> CreateControlPanel)
-> Lens
     CreateControlPanel CreateControlPanel (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateControlPanel' {Maybe Text
clientToken :: Maybe Text
$sel:clientToken:CreateControlPanel' :: CreateControlPanel -> Maybe Text
clientToken} -> Maybe Text
clientToken) (\s :: CreateControlPanel
s@CreateControlPanel' {} Maybe Text
a -> CreateControlPanel
s {$sel:clientToken:CreateControlPanel' :: Maybe Text
clientToken = Maybe Text
a} :: CreateControlPanel)

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

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

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

instance Prelude.NFData CreateControlPanel

instance Core.ToHeaders CreateControlPanel where
  toHeaders :: CreateControlPanel -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateControlPanel -> 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 CreateControlPanel where
  toJSON :: CreateControlPanel -> Value
toJSON CreateControlPanel' {Maybe Text
Text
controlPanelName :: Text
clusterArn :: Text
clientToken :: Maybe Text
$sel:controlPanelName:CreateControlPanel' :: CreateControlPanel -> Text
$sel:clusterArn:CreateControlPanel' :: CreateControlPanel -> Text
$sel:clientToken:CreateControlPanel' :: CreateControlPanel -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ClientToken" 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
clientToken,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ClusterArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
clusterArn),
            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 CreateControlPanel where
  toPath :: CreateControlPanel -> ByteString
toPath = ByteString -> CreateControlPanel -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/controlpanel"

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

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

-- |
-- Create a value of 'CreateControlPanelResponse' 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', 'createControlPanelResponse_controlPanel' - Information about a control panel.
--
-- 'httpStatus', 'createControlPanelResponse_httpStatus' - The response's http status code.
newCreateControlPanelResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateControlPanelResponse
newCreateControlPanelResponse :: Int -> CreateControlPanelResponse
newCreateControlPanelResponse Int
pHttpStatus_ =
  CreateControlPanelResponse' :: Maybe ControlPanel -> Int -> CreateControlPanelResponse
CreateControlPanelResponse'
    { $sel:controlPanel:CreateControlPanelResponse' :: Maybe ControlPanel
controlPanel =
        Maybe ControlPanel
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateControlPanelResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Information about a control panel.
createControlPanelResponse_controlPanel :: Lens.Lens' CreateControlPanelResponse (Prelude.Maybe ControlPanel)
createControlPanelResponse_controlPanel :: (Maybe ControlPanel -> f (Maybe ControlPanel))
-> CreateControlPanelResponse -> f CreateControlPanelResponse
createControlPanelResponse_controlPanel = (CreateControlPanelResponse -> Maybe ControlPanel)
-> (CreateControlPanelResponse
    -> Maybe ControlPanel -> CreateControlPanelResponse)
-> Lens
     CreateControlPanelResponse
     CreateControlPanelResponse
     (Maybe ControlPanel)
     (Maybe ControlPanel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateControlPanelResponse' {Maybe ControlPanel
controlPanel :: Maybe ControlPanel
$sel:controlPanel:CreateControlPanelResponse' :: CreateControlPanelResponse -> Maybe ControlPanel
controlPanel} -> Maybe ControlPanel
controlPanel) (\s :: CreateControlPanelResponse
s@CreateControlPanelResponse' {} Maybe ControlPanel
a -> CreateControlPanelResponse
s {$sel:controlPanel:CreateControlPanelResponse' :: Maybe ControlPanel
controlPanel = Maybe ControlPanel
a} :: CreateControlPanelResponse)

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

instance Prelude.NFData CreateControlPanelResponse