{-# 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.ArcZonalShift.GetManagedResource
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get information about a resource that\'s been registered for zonal
-- shifts with Amazon Route 53 Application Recovery Controller in this AWS
-- Region. Resources that are registered for zonal shifts are managed
-- resources in Route 53 ARC.
--
-- At this time, you can only start a zonal shift for Network Load
-- Balancers and Application Load Balancers with cross-zone load balancing
-- turned off.
module Amazonka.ArcZonalShift.GetManagedResource
  ( -- * Creating a Request
    GetManagedResource (..),
    newGetManagedResource,

    -- * Request Lenses
    getManagedResource_resourceIdentifier,

    -- * Destructuring the Response
    GetManagedResourceResponse (..),
    newGetManagedResourceResponse,

    -- * Response Lenses
    getManagedResourceResponse_arn,
    getManagedResourceResponse_name,
    getManagedResourceResponse_httpStatus,
    getManagedResourceResponse_appliedWeights,
    getManagedResourceResponse_zonalShifts,
  )
where

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

-- | /See:/ 'newGetManagedResource' smart constructor.
data GetManagedResource = GetManagedResource'
  { -- | The identifier for the resource to include in a zonal shift. The
    -- identifier is the Amazon Resource Name (ARN) for the resource.
    --
    -- At this time, you can only start a zonal shift for Network Load
    -- Balancers and Application Load Balancers with cross-zone load balancing
    -- turned off.
    GetManagedResource -> Text
resourceIdentifier :: Prelude.Text
  }
  deriving (GetManagedResource -> GetManagedResource -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetManagedResource -> GetManagedResource -> Bool
$c/= :: GetManagedResource -> GetManagedResource -> Bool
== :: GetManagedResource -> GetManagedResource -> Bool
$c== :: GetManagedResource -> GetManagedResource -> Bool
Prelude.Eq, ReadPrec [GetManagedResource]
ReadPrec GetManagedResource
Int -> ReadS GetManagedResource
ReadS [GetManagedResource]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetManagedResource]
$creadListPrec :: ReadPrec [GetManagedResource]
readPrec :: ReadPrec GetManagedResource
$creadPrec :: ReadPrec GetManagedResource
readList :: ReadS [GetManagedResource]
$creadList :: ReadS [GetManagedResource]
readsPrec :: Int -> ReadS GetManagedResource
$creadsPrec :: Int -> ReadS GetManagedResource
Prelude.Read, Int -> GetManagedResource -> ShowS
[GetManagedResource] -> ShowS
GetManagedResource -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetManagedResource] -> ShowS
$cshowList :: [GetManagedResource] -> ShowS
show :: GetManagedResource -> String
$cshow :: GetManagedResource -> String
showsPrec :: Int -> GetManagedResource -> ShowS
$cshowsPrec :: Int -> GetManagedResource -> ShowS
Prelude.Show, forall x. Rep GetManagedResource x -> GetManagedResource
forall x. GetManagedResource -> Rep GetManagedResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetManagedResource x -> GetManagedResource
$cfrom :: forall x. GetManagedResource -> Rep GetManagedResource x
Prelude.Generic)

-- |
-- Create a value of 'GetManagedResource' 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:
--
-- 'resourceIdentifier', 'getManagedResource_resourceIdentifier' - The identifier for the resource to include in a zonal shift. The
-- identifier is the Amazon Resource Name (ARN) for the resource.
--
-- At this time, you can only start a zonal shift for Network Load
-- Balancers and Application Load Balancers with cross-zone load balancing
-- turned off.
newGetManagedResource ::
  -- | 'resourceIdentifier'
  Prelude.Text ->
  GetManagedResource
newGetManagedResource :: Text -> GetManagedResource
newGetManagedResource Text
pResourceIdentifier_ =
  GetManagedResource'
    { $sel:resourceIdentifier:GetManagedResource' :: Text
resourceIdentifier =
        Text
pResourceIdentifier_
    }

-- | The identifier for the resource to include in a zonal shift. The
-- identifier is the Amazon Resource Name (ARN) for the resource.
--
-- At this time, you can only start a zonal shift for Network Load
-- Balancers and Application Load Balancers with cross-zone load balancing
-- turned off.
getManagedResource_resourceIdentifier :: Lens.Lens' GetManagedResource Prelude.Text
getManagedResource_resourceIdentifier :: Lens' GetManagedResource Text
getManagedResource_resourceIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetManagedResource' {Text
resourceIdentifier :: Text
$sel:resourceIdentifier:GetManagedResource' :: GetManagedResource -> Text
resourceIdentifier} -> Text
resourceIdentifier) (\s :: GetManagedResource
s@GetManagedResource' {} Text
a -> GetManagedResource
s {$sel:resourceIdentifier:GetManagedResource' :: Text
resourceIdentifier = Text
a} :: GetManagedResource)

instance Core.AWSRequest GetManagedResource where
  type
    AWSResponse GetManagedResource =
      GetManagedResourceResponse
  request :: (Service -> Service)
-> GetManagedResource -> Request GetManagedResource
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 GetManagedResource
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetManagedResource)))
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
-> Int
-> HashMap Text Double
-> [ZonalShiftInResource]
-> GetManagedResourceResponse
GetManagedResourceResponse'
            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
"arn")
            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
"name")
            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))
            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
"appliedWeights" 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
"zonalShifts" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
      )

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

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

instance Data.ToHeaders GetManagedResource where
  toHeaders :: GetManagedResource -> 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 GetManagedResource where
  toPath :: GetManagedResource -> ByteString
toPath GetManagedResource' {Text
resourceIdentifier :: Text
$sel:resourceIdentifier:GetManagedResource' :: GetManagedResource -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/managedresources/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
resourceIdentifier]

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

-- | /See:/ 'newGetManagedResourceResponse' smart constructor.
data GetManagedResourceResponse = GetManagedResourceResponse'
  { -- | The Amazon Resource Name (ARN) for the resource.
    GetManagedResourceResponse -> Maybe Text
arn :: Prelude.Maybe Prelude.Text,
    -- | The name of the resource.
    GetManagedResourceResponse -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    GetManagedResourceResponse -> Int
httpStatus :: Prelude.Int,
    -- | A collection of key-value pairs that indicate whether resources are
    -- active in Availability Zones or not. The key name is the Availability
    -- Zone where the resource is deployed. The value is 1 or 0.
    GetManagedResourceResponse -> HashMap Text Double
appliedWeights :: Prelude.HashMap Prelude.Text Prelude.Double,
    -- | The zonal shifts that are currently active for a resource.
    GetManagedResourceResponse -> [ZonalShiftInResource]
zonalShifts :: [ZonalShiftInResource]
  }
  deriving (GetManagedResourceResponse -> GetManagedResourceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetManagedResourceResponse -> GetManagedResourceResponse -> Bool
$c/= :: GetManagedResourceResponse -> GetManagedResourceResponse -> Bool
== :: GetManagedResourceResponse -> GetManagedResourceResponse -> Bool
$c== :: GetManagedResourceResponse -> GetManagedResourceResponse -> Bool
Prelude.Eq, ReadPrec [GetManagedResourceResponse]
ReadPrec GetManagedResourceResponse
Int -> ReadS GetManagedResourceResponse
ReadS [GetManagedResourceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetManagedResourceResponse]
$creadListPrec :: ReadPrec [GetManagedResourceResponse]
readPrec :: ReadPrec GetManagedResourceResponse
$creadPrec :: ReadPrec GetManagedResourceResponse
readList :: ReadS [GetManagedResourceResponse]
$creadList :: ReadS [GetManagedResourceResponse]
readsPrec :: Int -> ReadS GetManagedResourceResponse
$creadsPrec :: Int -> ReadS GetManagedResourceResponse
Prelude.Read, Int -> GetManagedResourceResponse -> ShowS
[GetManagedResourceResponse] -> ShowS
GetManagedResourceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetManagedResourceResponse] -> ShowS
$cshowList :: [GetManagedResourceResponse] -> ShowS
show :: GetManagedResourceResponse -> String
$cshow :: GetManagedResourceResponse -> String
showsPrec :: Int -> GetManagedResourceResponse -> ShowS
$cshowsPrec :: Int -> GetManagedResourceResponse -> ShowS
Prelude.Show, forall x.
Rep GetManagedResourceResponse x -> GetManagedResourceResponse
forall x.
GetManagedResourceResponse -> Rep GetManagedResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetManagedResourceResponse x -> GetManagedResourceResponse
$cfrom :: forall x.
GetManagedResourceResponse -> Rep GetManagedResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetManagedResourceResponse' 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:
--
-- 'arn', 'getManagedResourceResponse_arn' - The Amazon Resource Name (ARN) for the resource.
--
-- 'name', 'getManagedResourceResponse_name' - The name of the resource.
--
-- 'httpStatus', 'getManagedResourceResponse_httpStatus' - The response's http status code.
--
-- 'appliedWeights', 'getManagedResourceResponse_appliedWeights' - A collection of key-value pairs that indicate whether resources are
-- active in Availability Zones or not. The key name is the Availability
-- Zone where the resource is deployed. The value is 1 or 0.
--
-- 'zonalShifts', 'getManagedResourceResponse_zonalShifts' - The zonal shifts that are currently active for a resource.
newGetManagedResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetManagedResourceResponse
newGetManagedResourceResponse :: Int -> GetManagedResourceResponse
newGetManagedResourceResponse Int
pHttpStatus_ =
  GetManagedResourceResponse'
    { $sel:arn:GetManagedResourceResponse' :: Maybe Text
arn = forall a. Maybe a
Prelude.Nothing,
      $sel:name:GetManagedResourceResponse' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetManagedResourceResponse' :: Int
httpStatus = Int
pHttpStatus_,
      $sel:appliedWeights:GetManagedResourceResponse' :: HashMap Text Double
appliedWeights = forall a. Monoid a => a
Prelude.mempty,
      $sel:zonalShifts:GetManagedResourceResponse' :: [ZonalShiftInResource]
zonalShifts = forall a. Monoid a => a
Prelude.mempty
    }

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

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

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

-- | A collection of key-value pairs that indicate whether resources are
-- active in Availability Zones or not. The key name is the Availability
-- Zone where the resource is deployed. The value is 1 or 0.
getManagedResourceResponse_appliedWeights :: Lens.Lens' GetManagedResourceResponse (Prelude.HashMap Prelude.Text Prelude.Double)
getManagedResourceResponse_appliedWeights :: Lens' GetManagedResourceResponse (HashMap Text Double)
getManagedResourceResponse_appliedWeights = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetManagedResourceResponse' {HashMap Text Double
appliedWeights :: HashMap Text Double
$sel:appliedWeights:GetManagedResourceResponse' :: GetManagedResourceResponse -> HashMap Text Double
appliedWeights} -> HashMap Text Double
appliedWeights) (\s :: GetManagedResourceResponse
s@GetManagedResourceResponse' {} HashMap Text Double
a -> GetManagedResourceResponse
s {$sel:appliedWeights:GetManagedResourceResponse' :: HashMap Text Double
appliedWeights = HashMap Text Double
a} :: GetManagedResourceResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The zonal shifts that are currently active for a resource.
getManagedResourceResponse_zonalShifts :: Lens.Lens' GetManagedResourceResponse [ZonalShiftInResource]
getManagedResourceResponse_zonalShifts :: Lens' GetManagedResourceResponse [ZonalShiftInResource]
getManagedResourceResponse_zonalShifts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetManagedResourceResponse' {[ZonalShiftInResource]
zonalShifts :: [ZonalShiftInResource]
$sel:zonalShifts:GetManagedResourceResponse' :: GetManagedResourceResponse -> [ZonalShiftInResource]
zonalShifts} -> [ZonalShiftInResource]
zonalShifts) (\s :: GetManagedResourceResponse
s@GetManagedResourceResponse' {} [ZonalShiftInResource]
a -> GetManagedResourceResponse
s {$sel:zonalShifts:GetManagedResourceResponse' :: [ZonalShiftInResource]
zonalShifts = [ZonalShiftInResource]
a} :: GetManagedResourceResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.NFData GetManagedResourceResponse where
  rnf :: GetManagedResourceResponse -> ()
rnf GetManagedResourceResponse' {Int
[ZonalShiftInResource]
Maybe Text
HashMap Text Double
zonalShifts :: [ZonalShiftInResource]
appliedWeights :: HashMap Text Double
httpStatus :: Int
name :: Maybe Text
arn :: Maybe Text
$sel:zonalShifts:GetManagedResourceResponse' :: GetManagedResourceResponse -> [ZonalShiftInResource]
$sel:appliedWeights:GetManagedResourceResponse' :: GetManagedResourceResponse -> HashMap Text Double
$sel:httpStatus:GetManagedResourceResponse' :: GetManagedResourceResponse -> Int
$sel:name:GetManagedResourceResponse' :: GetManagedResourceResponse -> Maybe Text
$sel:arn:GetManagedResourceResponse' :: GetManagedResourceResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
arn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Double
appliedWeights
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf [ZonalShiftInResource]
zonalShifts