{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.Cluster
-- 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)
module Amazonka.Route53RecoveryControlConfig.Types.Cluster where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryControlConfig.Types.ClusterEndpoint
import Amazonka.Route53RecoveryControlConfig.Types.Status

-- | A cluster is a set of five consensus-forming Regional endpoints that
-- represent the infrastructure that hosts your routing controls.
-- Typically, you host together on one cluster all of the routing controls
-- for your applications.
--
-- /See:/ 'newCluster' smart constructor.
data Cluster = Cluster'
  { -- | Deployment status of a resource. Status can be one of the following:
    -- PENDING, DEPLOYED, PENDING_DELETION.
    Cluster -> Maybe Status
status :: Prelude.Maybe Status,
    -- | The Amazon Resource Name (ARN) of the cluster.
    Cluster -> Maybe Text
clusterArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the cluster.
    Cluster -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Endpoints for a cluster. Specify one of these endpoints when you want to
    -- set or retrieve a routing control state in the cluster.
    --
    -- To get or update the routing control state, see the Amazon Route 53
    -- Application Recovery Controller Cluster (Data Plane) Actions.
    Cluster -> Maybe [ClusterEndpoint]
clusterEndpoints :: Prelude.Maybe [ClusterEndpoint]
  }
  deriving (Cluster -> Cluster -> Bool
(Cluster -> Cluster -> Bool)
-> (Cluster -> Cluster -> Bool) -> Eq Cluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Cluster -> Cluster -> Bool
$c/= :: Cluster -> Cluster -> Bool
== :: Cluster -> Cluster -> Bool
$c== :: Cluster -> Cluster -> Bool
Prelude.Eq, ReadPrec [Cluster]
ReadPrec Cluster
Int -> ReadS Cluster
ReadS [Cluster]
(Int -> ReadS Cluster)
-> ReadS [Cluster]
-> ReadPrec Cluster
-> ReadPrec [Cluster]
-> Read Cluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Cluster]
$creadListPrec :: ReadPrec [Cluster]
readPrec :: ReadPrec Cluster
$creadPrec :: ReadPrec Cluster
readList :: ReadS [Cluster]
$creadList :: ReadS [Cluster]
readsPrec :: Int -> ReadS Cluster
$creadsPrec :: Int -> ReadS Cluster
Prelude.Read, Int -> Cluster -> ShowS
[Cluster] -> ShowS
Cluster -> String
(Int -> Cluster -> ShowS)
-> (Cluster -> String) -> ([Cluster] -> ShowS) -> Show Cluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Cluster] -> ShowS
$cshowList :: [Cluster] -> ShowS
show :: Cluster -> String
$cshow :: Cluster -> String
showsPrec :: Int -> Cluster -> ShowS
$cshowsPrec :: Int -> Cluster -> ShowS
Prelude.Show, (forall x. Cluster -> Rep Cluster x)
-> (forall x. Rep Cluster x -> Cluster) -> Generic Cluster
forall x. Rep Cluster x -> Cluster
forall x. Cluster -> Rep Cluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Cluster x -> Cluster
$cfrom :: forall x. Cluster -> Rep Cluster x
Prelude.Generic)

-- |
-- Create a value of 'Cluster' 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:
--
-- 'status', 'cluster_status' - Deployment status of a resource. Status can be one of the following:
-- PENDING, DEPLOYED, PENDING_DELETION.
--
-- 'clusterArn', 'cluster_clusterArn' - The Amazon Resource Name (ARN) of the cluster.
--
-- 'name', 'cluster_name' - The name of the cluster.
--
-- 'clusterEndpoints', 'cluster_clusterEndpoints' - Endpoints for a cluster. Specify one of these endpoints when you want to
-- set or retrieve a routing control state in the cluster.
--
-- To get or update the routing control state, see the Amazon Route 53
-- Application Recovery Controller Cluster (Data Plane) Actions.
newCluster ::
  Cluster
newCluster :: Cluster
newCluster =
  Cluster' :: Maybe Status
-> Maybe Text -> Maybe Text -> Maybe [ClusterEndpoint] -> Cluster
Cluster'
    { $sel:status:Cluster' :: Maybe Status
status = Maybe Status
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterArn:Cluster' :: Maybe Text
clusterArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Cluster' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterEndpoints:Cluster' :: Maybe [ClusterEndpoint]
clusterEndpoints = Maybe [ClusterEndpoint]
forall a. Maybe a
Prelude.Nothing
    }

-- | Deployment status of a resource. Status can be one of the following:
-- PENDING, DEPLOYED, PENDING_DELETION.
cluster_status :: Lens.Lens' Cluster (Prelude.Maybe Status)
cluster_status :: (Maybe Status -> f (Maybe Status)) -> Cluster -> f Cluster
cluster_status = (Cluster -> Maybe Status)
-> (Cluster -> Maybe Status -> Cluster)
-> Lens Cluster Cluster (Maybe Status) (Maybe Status)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cluster' {Maybe Status
status :: Maybe Status
$sel:status:Cluster' :: Cluster -> Maybe Status
status} -> Maybe Status
status) (\s :: Cluster
s@Cluster' {} Maybe Status
a -> Cluster
s {$sel:status:Cluster' :: Maybe Status
status = Maybe Status
a} :: Cluster)

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

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

-- | Endpoints for a cluster. Specify one of these endpoints when you want to
-- set or retrieve a routing control state in the cluster.
--
-- To get or update the routing control state, see the Amazon Route 53
-- Application Recovery Controller Cluster (Data Plane) Actions.
cluster_clusterEndpoints :: Lens.Lens' Cluster (Prelude.Maybe [ClusterEndpoint])
cluster_clusterEndpoints :: (Maybe [ClusterEndpoint] -> f (Maybe [ClusterEndpoint]))
-> Cluster -> f Cluster
cluster_clusterEndpoints = (Cluster -> Maybe [ClusterEndpoint])
-> (Cluster -> Maybe [ClusterEndpoint] -> Cluster)
-> Lens
     Cluster Cluster (Maybe [ClusterEndpoint]) (Maybe [ClusterEndpoint])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Cluster' {Maybe [ClusterEndpoint]
clusterEndpoints :: Maybe [ClusterEndpoint]
$sel:clusterEndpoints:Cluster' :: Cluster -> Maybe [ClusterEndpoint]
clusterEndpoints} -> Maybe [ClusterEndpoint]
clusterEndpoints) (\s :: Cluster
s@Cluster' {} Maybe [ClusterEndpoint]
a -> Cluster
s {$sel:clusterEndpoints:Cluster' :: Maybe [ClusterEndpoint]
clusterEndpoints = Maybe [ClusterEndpoint]
a} :: Cluster) ((Maybe [ClusterEndpoint] -> f (Maybe [ClusterEndpoint]))
 -> Cluster -> f Cluster)
-> ((Maybe [ClusterEndpoint] -> f (Maybe [ClusterEndpoint]))
    -> Maybe [ClusterEndpoint] -> f (Maybe [ClusterEndpoint]))
-> (Maybe [ClusterEndpoint] -> f (Maybe [ClusterEndpoint]))
-> Cluster
-> f Cluster
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [ClusterEndpoint]
  [ClusterEndpoint]
  [ClusterEndpoint]
  [ClusterEndpoint]
-> Iso
     (Maybe [ClusterEndpoint])
     (Maybe [ClusterEndpoint])
     (Maybe [ClusterEndpoint])
     (Maybe [ClusterEndpoint])
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
  [ClusterEndpoint]
  [ClusterEndpoint]
  [ClusterEndpoint]
  [ClusterEndpoint]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON Cluster where
  parseJSON :: Value -> Parser Cluster
parseJSON =
    String -> (Object -> Parser Cluster) -> Value -> Parser Cluster
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Cluster"
      ( \Object
x ->
          Maybe Status
-> Maybe Text -> Maybe Text -> Maybe [ClusterEndpoint] -> Cluster
Cluster'
            (Maybe Status
 -> Maybe Text -> Maybe Text -> Maybe [ClusterEndpoint] -> Cluster)
-> Parser (Maybe Status)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe [ClusterEndpoint] -> Cluster)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Status)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Status")
            Parser
  (Maybe Text -> Maybe Text -> Maybe [ClusterEndpoint] -> Cluster)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [ClusterEndpoint] -> Cluster)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClusterArn")
            Parser (Maybe Text -> Maybe [ClusterEndpoint] -> Cluster)
-> Parser (Maybe Text)
-> Parser (Maybe [ClusterEndpoint] -> Cluster)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Name")
            Parser (Maybe [ClusterEndpoint] -> Cluster)
-> Parser (Maybe [ClusterEndpoint]) -> Parser Cluster
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [ClusterEndpoint]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ClusterEndpoints"
                            Parser (Maybe (Maybe [ClusterEndpoint]))
-> Maybe [ClusterEndpoint] -> Parser (Maybe [ClusterEndpoint])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [ClusterEndpoint]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable Cluster

instance Prelude.NFData Cluster