{-# 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.Route53RecoveryReadiness.Types.Resource
-- 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.Route53RecoveryReadiness.Types.Resource where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryReadiness.Types.DNSTargetResource

-- | The resource element of a ResourceSet
--
-- /See:/ 'newResource' smart constructor.
data Resource = Resource'
  { -- | A list of RecoveryGroup ARNs and\/or Cell ARNs that this resource is
    -- contained within.
    Resource -> Maybe [Text]
readinessScopes :: Prelude.Maybe [Prelude.Text],
    -- | The ARN of the AWS resource, can be skipped if dnsTargetResource is used
    Resource -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The component id of the resource, generated by the service when
    -- dnsTargetResource is used
    Resource -> Maybe Text
componentId :: Prelude.Maybe Prelude.Text,
    Resource -> Maybe DNSTargetResource
dnsTargetResource :: Prelude.Maybe DNSTargetResource
  }
  deriving (Resource -> Resource -> Bool
(Resource -> Resource -> Bool)
-> (Resource -> Resource -> Bool) -> Eq Resource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Resource -> Resource -> Bool
$c/= :: Resource -> Resource -> Bool
== :: Resource -> Resource -> Bool
$c== :: Resource -> Resource -> Bool
Prelude.Eq, ReadPrec [Resource]
ReadPrec Resource
Int -> ReadS Resource
ReadS [Resource]
(Int -> ReadS Resource)
-> ReadS [Resource]
-> ReadPrec Resource
-> ReadPrec [Resource]
-> Read Resource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Resource]
$creadListPrec :: ReadPrec [Resource]
readPrec :: ReadPrec Resource
$creadPrec :: ReadPrec Resource
readList :: ReadS [Resource]
$creadList :: ReadS [Resource]
readsPrec :: Int -> ReadS Resource
$creadsPrec :: Int -> ReadS Resource
Prelude.Read, Int -> Resource -> ShowS
[Resource] -> ShowS
Resource -> String
(Int -> Resource -> ShowS)
-> (Resource -> String) -> ([Resource] -> ShowS) -> Show Resource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Resource] -> ShowS
$cshowList :: [Resource] -> ShowS
show :: Resource -> String
$cshow :: Resource -> String
showsPrec :: Int -> Resource -> ShowS
$cshowsPrec :: Int -> Resource -> ShowS
Prelude.Show, (forall x. Resource -> Rep Resource x)
-> (forall x. Rep Resource x -> Resource) -> Generic Resource
forall x. Rep Resource x -> Resource
forall x. Resource -> Rep Resource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Resource x -> Resource
$cfrom :: forall x. Resource -> Rep Resource x
Prelude.Generic)

-- |
-- Create a value of 'Resource' 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:
--
-- 'readinessScopes', 'resource_readinessScopes' - A list of RecoveryGroup ARNs and\/or Cell ARNs that this resource is
-- contained within.
--
-- 'resourceArn', 'resource_resourceArn' - The ARN of the AWS resource, can be skipped if dnsTargetResource is used
--
-- 'componentId', 'resource_componentId' - The component id of the resource, generated by the service when
-- dnsTargetResource is used
--
-- 'dnsTargetResource', 'resource_dnsTargetResource' - Undocumented member.
newResource ::
  Resource
newResource :: Resource
newResource =
  Resource' :: Maybe [Text]
-> Maybe Text -> Maybe Text -> Maybe DNSTargetResource -> Resource
Resource'
    { $sel:readinessScopes:Resource' :: Maybe [Text]
readinessScopes = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:Resource' :: Maybe Text
resourceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:componentId:Resource' :: Maybe Text
componentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dnsTargetResource:Resource' :: Maybe DNSTargetResource
dnsTargetResource = Maybe DNSTargetResource
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of RecoveryGroup ARNs and\/or Cell ARNs that this resource is
-- contained within.
resource_readinessScopes :: Lens.Lens' Resource (Prelude.Maybe [Prelude.Text])
resource_readinessScopes :: (Maybe [Text] -> f (Maybe [Text])) -> Resource -> f Resource
resource_readinessScopes = (Resource -> Maybe [Text])
-> (Resource -> Maybe [Text] -> Resource)
-> Lens Resource Resource (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe [Text]
readinessScopes :: Maybe [Text]
$sel:readinessScopes:Resource' :: Resource -> Maybe [Text]
readinessScopes} -> Maybe [Text]
readinessScopes) (\s :: Resource
s@Resource' {} Maybe [Text]
a -> Resource
s {$sel:readinessScopes:Resource' :: Maybe [Text]
readinessScopes = Maybe [Text]
a} :: Resource) ((Maybe [Text] -> f (Maybe [Text])) -> Resource -> f Resource)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Resource
-> f Resource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the AWS resource, can be skipped if dnsTargetResource is used
resource_resourceArn :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_resourceArn :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_resourceArn = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:Resource' :: Resource -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:resourceArn:Resource' :: Maybe Text
resourceArn = Maybe Text
a} :: Resource)

-- | The component id of the resource, generated by the service when
-- dnsTargetResource is used
resource_componentId :: Lens.Lens' Resource (Prelude.Maybe Prelude.Text)
resource_componentId :: (Maybe Text -> f (Maybe Text)) -> Resource -> f Resource
resource_componentId = (Resource -> Maybe Text)
-> (Resource -> Maybe Text -> Resource)
-> Lens Resource Resource (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe Text
componentId :: Maybe Text
$sel:componentId:Resource' :: Resource -> Maybe Text
componentId} -> Maybe Text
componentId) (\s :: Resource
s@Resource' {} Maybe Text
a -> Resource
s {$sel:componentId:Resource' :: Maybe Text
componentId = Maybe Text
a} :: Resource)

-- | Undocumented member.
resource_dnsTargetResource :: Lens.Lens' Resource (Prelude.Maybe DNSTargetResource)
resource_dnsTargetResource :: (Maybe DNSTargetResource -> f (Maybe DNSTargetResource))
-> Resource -> f Resource
resource_dnsTargetResource = (Resource -> Maybe DNSTargetResource)
-> (Resource -> Maybe DNSTargetResource -> Resource)
-> Lens
     Resource
     Resource
     (Maybe DNSTargetResource)
     (Maybe DNSTargetResource)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Resource' {Maybe DNSTargetResource
dnsTargetResource :: Maybe DNSTargetResource
$sel:dnsTargetResource:Resource' :: Resource -> Maybe DNSTargetResource
dnsTargetResource} -> Maybe DNSTargetResource
dnsTargetResource) (\s :: Resource
s@Resource' {} Maybe DNSTargetResource
a -> Resource
s {$sel:dnsTargetResource:Resource' :: Maybe DNSTargetResource
dnsTargetResource = Maybe DNSTargetResource
a} :: Resource)

instance Core.FromJSON Resource where
  parseJSON :: Value -> Parser Resource
parseJSON =
    String -> (Object -> Parser Resource) -> Value -> Parser Resource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Resource"
      ( \Object
x ->
          Maybe [Text]
-> Maybe Text -> Maybe Text -> Maybe DNSTargetResource -> Resource
Resource'
            (Maybe [Text]
 -> Maybe Text -> Maybe Text -> Maybe DNSTargetResource -> Resource)
-> Parser (Maybe [Text])
-> Parser
     (Maybe Text -> Maybe Text -> Maybe DNSTargetResource -> Resource)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"readinessScopes"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text -> Maybe Text -> Maybe DNSTargetResource -> Resource)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe DNSTargetResource -> Resource)
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
"resourceArn")
            Parser (Maybe Text -> Maybe DNSTargetResource -> Resource)
-> Parser (Maybe Text)
-> Parser (Maybe DNSTargetResource -> Resource)
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
"componentId")
            Parser (Maybe DNSTargetResource -> Resource)
-> Parser (Maybe DNSTargetResource) -> Parser Resource
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe DNSTargetResource)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"dnsTargetResource")
      )

instance Prelude.Hashable Resource

instance Prelude.NFData Resource

instance Core.ToJSON Resource where
  toJSON :: Resource -> Value
toJSON Resource' {Maybe [Text]
Maybe Text
Maybe DNSTargetResource
dnsTargetResource :: Maybe DNSTargetResource
componentId :: Maybe Text
resourceArn :: Maybe Text
readinessScopes :: Maybe [Text]
$sel:dnsTargetResource:Resource' :: Resource -> Maybe DNSTargetResource
$sel:componentId:Resource' :: Resource -> Maybe Text
$sel:resourceArn:Resource' :: Resource -> Maybe Text
$sel:readinessScopes:Resource' :: Resource -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"readinessScopes" 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]
readinessScopes,
            (Text
"resourceArn" 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
resourceArn,
            (Text
"componentId" 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
componentId,
            (Text
"dnsTargetResource" Text -> DNSTargetResource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DNSTargetResource -> Pair)
-> Maybe DNSTargetResource -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DNSTargetResource
dnsTargetResource
          ]
      )