{-# 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.Route53RecoveryReadiness.GetCell
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about a cell including cell name, cell Amazon Resource
-- Name (ARN), ARNs of nested cells for this cell, and a list of those cell
-- ARNs with their associated recovery group ARNs.
module Amazonka.Route53RecoveryReadiness.GetCell
  ( -- * Creating a Request
    GetCell (..),
    newGetCell,

    -- * Request Lenses
    getCell_cellName,

    -- * Destructuring the Response
    GetCellResponse (..),
    newGetCellResponse,

    -- * Response Lenses
    getCellResponse_cellArn,
    getCellResponse_cellName,
    getCellResponse_cells,
    getCellResponse_parentReadinessScopes,
    getCellResponse_tags,
    getCellResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.Route53RecoveryReadiness.Types

-- | /See:/ 'newGetCell' smart constructor.
data GetCell = GetCell'
  { -- | The name of the cell.
    GetCell -> Text
cellName :: Prelude.Text
  }
  deriving (GetCell -> GetCell -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCell -> GetCell -> Bool
$c/= :: GetCell -> GetCell -> Bool
== :: GetCell -> GetCell -> Bool
$c== :: GetCell -> GetCell -> Bool
Prelude.Eq, ReadPrec [GetCell]
ReadPrec GetCell
Int -> ReadS GetCell
ReadS [GetCell]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCell]
$creadListPrec :: ReadPrec [GetCell]
readPrec :: ReadPrec GetCell
$creadPrec :: ReadPrec GetCell
readList :: ReadS [GetCell]
$creadList :: ReadS [GetCell]
readsPrec :: Int -> ReadS GetCell
$creadsPrec :: Int -> ReadS GetCell
Prelude.Read, Int -> GetCell -> ShowS
[GetCell] -> ShowS
GetCell -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCell] -> ShowS
$cshowList :: [GetCell] -> ShowS
show :: GetCell -> String
$cshow :: GetCell -> String
showsPrec :: Int -> GetCell -> ShowS
$cshowsPrec :: Int -> GetCell -> ShowS
Prelude.Show, forall x. Rep GetCell x -> GetCell
forall x. GetCell -> Rep GetCell x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCell x -> GetCell
$cfrom :: forall x. GetCell -> Rep GetCell x
Prelude.Generic)

-- |
-- Create a value of 'GetCell' 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:
--
-- 'cellName', 'getCell_cellName' - The name of the cell.
newGetCell ::
  -- | 'cellName'
  Prelude.Text ->
  GetCell
newGetCell :: Text -> GetCell
newGetCell Text
pCellName_ =
  GetCell' {$sel:cellName:GetCell' :: Text
cellName = Text
pCellName_}

-- | The name of the cell.
getCell_cellName :: Lens.Lens' GetCell Prelude.Text
getCell_cellName :: Lens' GetCell Text
getCell_cellName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCell' {Text
cellName :: Text
$sel:cellName:GetCell' :: GetCell -> Text
cellName} -> Text
cellName) (\s :: GetCell
s@GetCell' {} Text
a -> GetCell
s {$sel:cellName:GetCell' :: Text
cellName = Text
a} :: GetCell)

instance Core.AWSRequest GetCell where
  type AWSResponse GetCell = GetCellResponse
  request :: (Service -> Service) -> GetCell -> Request GetCell
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetCell
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCell)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [Text]
-> Maybe [Text]
-> Maybe (HashMap Text Text)
-> Int
-> GetCellResponse
GetCellResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"cellArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"cellName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"cells" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"parentReadinessScopes"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"tags" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable GetCell where
  hashWithSalt :: Int -> GetCell -> Int
hashWithSalt Int
_salt GetCell' {Text
cellName :: Text
$sel:cellName:GetCell' :: GetCell -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
cellName

instance Prelude.NFData GetCell where
  rnf :: GetCell -> ()
rnf GetCell' {Text
cellName :: Text
$sel:cellName:GetCell' :: GetCell -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
cellName

instance Data.ToHeaders GetCell where
  toHeaders :: GetCell -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath GetCell where
  toPath :: GetCell -> ByteString
toPath GetCell' {Text
cellName :: Text
$sel:cellName:GetCell' :: GetCell -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/cells/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
cellName]

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

-- | /See:/ 'newGetCellResponse' smart constructor.
data GetCellResponse = GetCellResponse'
  { -- | The Amazon Resource Name (ARN) for the cell.
    GetCellResponse -> Maybe Text
cellArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the cell.
    GetCellResponse -> Maybe Text
cellName :: Prelude.Maybe Prelude.Text,
    -- | A list of cell ARNs.
    GetCellResponse -> Maybe [Text]
cells :: Prelude.Maybe [Prelude.Text],
    -- | The readiness scope for the cell, which can be a cell Amazon Resource
    -- Name (ARN) or a recovery group ARN. This is a list but currently can
    -- have only one element.
    GetCellResponse -> Maybe [Text]
parentReadinessScopes :: Prelude.Maybe [Prelude.Text],
    -- | Tags on the resources.
    GetCellResponse -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The response's http status code.
    GetCellResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetCellResponse -> GetCellResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCellResponse -> GetCellResponse -> Bool
$c/= :: GetCellResponse -> GetCellResponse -> Bool
== :: GetCellResponse -> GetCellResponse -> Bool
$c== :: GetCellResponse -> GetCellResponse -> Bool
Prelude.Eq, ReadPrec [GetCellResponse]
ReadPrec GetCellResponse
Int -> ReadS GetCellResponse
ReadS [GetCellResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCellResponse]
$creadListPrec :: ReadPrec [GetCellResponse]
readPrec :: ReadPrec GetCellResponse
$creadPrec :: ReadPrec GetCellResponse
readList :: ReadS [GetCellResponse]
$creadList :: ReadS [GetCellResponse]
readsPrec :: Int -> ReadS GetCellResponse
$creadsPrec :: Int -> ReadS GetCellResponse
Prelude.Read, Int -> GetCellResponse -> ShowS
[GetCellResponse] -> ShowS
GetCellResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCellResponse] -> ShowS
$cshowList :: [GetCellResponse] -> ShowS
show :: GetCellResponse -> String
$cshow :: GetCellResponse -> String
showsPrec :: Int -> GetCellResponse -> ShowS
$cshowsPrec :: Int -> GetCellResponse -> ShowS
Prelude.Show, forall x. Rep GetCellResponse x -> GetCellResponse
forall x. GetCellResponse -> Rep GetCellResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCellResponse x -> GetCellResponse
$cfrom :: forall x. GetCellResponse -> Rep GetCellResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetCellResponse' 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:
--
-- 'cellArn', 'getCellResponse_cellArn' - The Amazon Resource Name (ARN) for the cell.
--
-- 'cellName', 'getCellResponse_cellName' - The name of the cell.
--
-- 'cells', 'getCellResponse_cells' - A list of cell ARNs.
--
-- 'parentReadinessScopes', 'getCellResponse_parentReadinessScopes' - The readiness scope for the cell, which can be a cell Amazon Resource
-- Name (ARN) or a recovery group ARN. This is a list but currently can
-- have only one element.
--
-- 'tags', 'getCellResponse_tags' - Tags on the resources.
--
-- 'httpStatus', 'getCellResponse_httpStatus' - The response's http status code.
newGetCellResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCellResponse
newGetCellResponse :: Int -> GetCellResponse
newGetCellResponse Int
pHttpStatus_ =
  GetCellResponse'
    { $sel:cellArn:GetCellResponse' :: Maybe Text
cellArn = forall a. Maybe a
Prelude.Nothing,
      $sel:cellName:GetCellResponse' :: Maybe Text
cellName = forall a. Maybe a
Prelude.Nothing,
      $sel:cells:GetCellResponse' :: Maybe [Text]
cells = forall a. Maybe a
Prelude.Nothing,
      $sel:parentReadinessScopes:GetCellResponse' :: Maybe [Text]
parentReadinessScopes = forall a. Maybe a
Prelude.Nothing,
      $sel:tags:GetCellResponse' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCellResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) for the cell.
getCellResponse_cellArn :: Lens.Lens' GetCellResponse (Prelude.Maybe Prelude.Text)
getCellResponse_cellArn :: Lens' GetCellResponse (Maybe Text)
getCellResponse_cellArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCellResponse' {Maybe Text
cellArn :: Maybe Text
$sel:cellArn:GetCellResponse' :: GetCellResponse -> Maybe Text
cellArn} -> Maybe Text
cellArn) (\s :: GetCellResponse
s@GetCellResponse' {} Maybe Text
a -> GetCellResponse
s {$sel:cellArn:GetCellResponse' :: Maybe Text
cellArn = Maybe Text
a} :: GetCellResponse)

-- | The name of the cell.
getCellResponse_cellName :: Lens.Lens' GetCellResponse (Prelude.Maybe Prelude.Text)
getCellResponse_cellName :: Lens' GetCellResponse (Maybe Text)
getCellResponse_cellName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCellResponse' {Maybe Text
cellName :: Maybe Text
$sel:cellName:GetCellResponse' :: GetCellResponse -> Maybe Text
cellName} -> Maybe Text
cellName) (\s :: GetCellResponse
s@GetCellResponse' {} Maybe Text
a -> GetCellResponse
s {$sel:cellName:GetCellResponse' :: Maybe Text
cellName = Maybe Text
a} :: GetCellResponse)

-- | A list of cell ARNs.
getCellResponse_cells :: Lens.Lens' GetCellResponse (Prelude.Maybe [Prelude.Text])
getCellResponse_cells :: Lens' GetCellResponse (Maybe [Text])
getCellResponse_cells = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCellResponse' {Maybe [Text]
cells :: Maybe [Text]
$sel:cells:GetCellResponse' :: GetCellResponse -> Maybe [Text]
cells} -> Maybe [Text]
cells) (\s :: GetCellResponse
s@GetCellResponse' {} Maybe [Text]
a -> GetCellResponse
s {$sel:cells:GetCellResponse' :: Maybe [Text]
cells = Maybe [Text]
a} :: GetCellResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The readiness scope for the cell, which can be a cell Amazon Resource
-- Name (ARN) or a recovery group ARN. This is a list but currently can
-- have only one element.
getCellResponse_parentReadinessScopes :: Lens.Lens' GetCellResponse (Prelude.Maybe [Prelude.Text])
getCellResponse_parentReadinessScopes :: Lens' GetCellResponse (Maybe [Text])
getCellResponse_parentReadinessScopes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCellResponse' {Maybe [Text]
parentReadinessScopes :: Maybe [Text]
$sel:parentReadinessScopes:GetCellResponse' :: GetCellResponse -> Maybe [Text]
parentReadinessScopes} -> Maybe [Text]
parentReadinessScopes) (\s :: GetCellResponse
s@GetCellResponse' {} Maybe [Text]
a -> GetCellResponse
s {$sel:parentReadinessScopes:GetCellResponse' :: Maybe [Text]
parentReadinessScopes = Maybe [Text]
a} :: GetCellResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Tags on the resources.
getCellResponse_tags :: Lens.Lens' GetCellResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getCellResponse_tags :: Lens' GetCellResponse (Maybe (HashMap Text Text))
getCellResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCellResponse' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:GetCellResponse' :: GetCellResponse -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: GetCellResponse
s@GetCellResponse' {} Maybe (HashMap Text Text)
a -> GetCellResponse
s {$sel:tags:GetCellResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: GetCellResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetCellResponse where
  rnf :: GetCellResponse -> ()
rnf GetCellResponse' {Int
Maybe [Text]
Maybe Text
Maybe (HashMap Text Text)
httpStatus :: Int
tags :: Maybe (HashMap Text Text)
parentReadinessScopes :: Maybe [Text]
cells :: Maybe [Text]
cellName :: Maybe Text
cellArn :: Maybe Text
$sel:httpStatus:GetCellResponse' :: GetCellResponse -> Int
$sel:tags:GetCellResponse' :: GetCellResponse -> Maybe (HashMap Text Text)
$sel:parentReadinessScopes:GetCellResponse' :: GetCellResponse -> Maybe [Text]
$sel:cells:GetCellResponse' :: GetCellResponse -> Maybe [Text]
$sel:cellName:GetCellResponse' :: GetCellResponse -> Maybe Text
$sel:cellArn:GetCellResponse' :: GetCellResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cellArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
cellName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
cells
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Text]
parentReadinessScopes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus