{-# 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.CloudFormation.Types.ResourceIdentifierSummary
-- 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.CloudFormation.Types.ResourceIdentifierSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Describes the target resources of a specific type in your import
-- template (for example, all @AWS::S3::Bucket@ resources) and the
-- properties you can provide during the import to identify resources of
-- that type.
--
-- /See:/ 'newResourceIdentifierSummary' smart constructor.
data ResourceIdentifierSummary = ResourceIdentifierSummary'
  { -- | The template resource type of the target resources, such as
    -- @AWS::S3::Bucket@.
    ResourceIdentifierSummary -> Maybe Text
resourceType :: Prelude.Maybe Prelude.Text,
    -- | The logical IDs of the target resources of the specified @ResourceType@,
    -- as defined in the import template.
    ResourceIdentifierSummary -> Maybe (NonEmpty Text)
logicalResourceIds :: Prelude.Maybe (Prelude.NonEmpty Prelude.Text),
    -- | The resource properties you can provide during the import to identify
    -- your target resources. For example, @BucketName@ is a possible
    -- identifier property for @AWS::S3::Bucket@ resources.
    ResourceIdentifierSummary -> Maybe [Text]
resourceIdentifiers :: Prelude.Maybe [Prelude.Text]
  }
  deriving (ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool
(ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool)
-> (ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool)
-> Eq ResourceIdentifierSummary
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool
$c/= :: ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool
== :: ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool
$c== :: ResourceIdentifierSummary -> ResourceIdentifierSummary -> Bool
Prelude.Eq, ReadPrec [ResourceIdentifierSummary]
ReadPrec ResourceIdentifierSummary
Int -> ReadS ResourceIdentifierSummary
ReadS [ResourceIdentifierSummary]
(Int -> ReadS ResourceIdentifierSummary)
-> ReadS [ResourceIdentifierSummary]
-> ReadPrec ResourceIdentifierSummary
-> ReadPrec [ResourceIdentifierSummary]
-> Read ResourceIdentifierSummary
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceIdentifierSummary]
$creadListPrec :: ReadPrec [ResourceIdentifierSummary]
readPrec :: ReadPrec ResourceIdentifierSummary
$creadPrec :: ReadPrec ResourceIdentifierSummary
readList :: ReadS [ResourceIdentifierSummary]
$creadList :: ReadS [ResourceIdentifierSummary]
readsPrec :: Int -> ReadS ResourceIdentifierSummary
$creadsPrec :: Int -> ReadS ResourceIdentifierSummary
Prelude.Read, Int -> ResourceIdentifierSummary -> ShowS
[ResourceIdentifierSummary] -> ShowS
ResourceIdentifierSummary -> String
(Int -> ResourceIdentifierSummary -> ShowS)
-> (ResourceIdentifierSummary -> String)
-> ([ResourceIdentifierSummary] -> ShowS)
-> Show ResourceIdentifierSummary
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceIdentifierSummary] -> ShowS
$cshowList :: [ResourceIdentifierSummary] -> ShowS
show :: ResourceIdentifierSummary -> String
$cshow :: ResourceIdentifierSummary -> String
showsPrec :: Int -> ResourceIdentifierSummary -> ShowS
$cshowsPrec :: Int -> ResourceIdentifierSummary -> ShowS
Prelude.Show, (forall x.
 ResourceIdentifierSummary -> Rep ResourceIdentifierSummary x)
-> (forall x.
    Rep ResourceIdentifierSummary x -> ResourceIdentifierSummary)
-> Generic ResourceIdentifierSummary
forall x.
Rep ResourceIdentifierSummary x -> ResourceIdentifierSummary
forall x.
ResourceIdentifierSummary -> Rep ResourceIdentifierSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ResourceIdentifierSummary x -> ResourceIdentifierSummary
$cfrom :: forall x.
ResourceIdentifierSummary -> Rep ResourceIdentifierSummary x
Prelude.Generic)

-- |
-- Create a value of 'ResourceIdentifierSummary' 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:
--
-- 'resourceType', 'resourceIdentifierSummary_resourceType' - The template resource type of the target resources, such as
-- @AWS::S3::Bucket@.
--
-- 'logicalResourceIds', 'resourceIdentifierSummary_logicalResourceIds' - The logical IDs of the target resources of the specified @ResourceType@,
-- as defined in the import template.
--
-- 'resourceIdentifiers', 'resourceIdentifierSummary_resourceIdentifiers' - The resource properties you can provide during the import to identify
-- your target resources. For example, @BucketName@ is a possible
-- identifier property for @AWS::S3::Bucket@ resources.
newResourceIdentifierSummary ::
  ResourceIdentifierSummary
newResourceIdentifierSummary :: ResourceIdentifierSummary
newResourceIdentifierSummary =
  ResourceIdentifierSummary' :: Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe [Text]
-> ResourceIdentifierSummary
ResourceIdentifierSummary'
    { $sel:resourceType:ResourceIdentifierSummary' :: Maybe Text
resourceType =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logicalResourceIds:ResourceIdentifierSummary' :: Maybe (NonEmpty Text)
logicalResourceIds = Maybe (NonEmpty Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceIdentifiers:ResourceIdentifierSummary' :: Maybe [Text]
resourceIdentifiers = Maybe [Text]
forall a. Maybe a
Prelude.Nothing
    }

-- | The template resource type of the target resources, such as
-- @AWS::S3::Bucket@.
resourceIdentifierSummary_resourceType :: Lens.Lens' ResourceIdentifierSummary (Prelude.Maybe Prelude.Text)
resourceIdentifierSummary_resourceType :: (Maybe Text -> f (Maybe Text))
-> ResourceIdentifierSummary -> f ResourceIdentifierSummary
resourceIdentifierSummary_resourceType = (ResourceIdentifierSummary -> Maybe Text)
-> (ResourceIdentifierSummary
    -> Maybe Text -> ResourceIdentifierSummary)
-> Lens
     ResourceIdentifierSummary
     ResourceIdentifierSummary
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceIdentifierSummary' {Maybe Text
resourceType :: Maybe Text
$sel:resourceType:ResourceIdentifierSummary' :: ResourceIdentifierSummary -> Maybe Text
resourceType} -> Maybe Text
resourceType) (\s :: ResourceIdentifierSummary
s@ResourceIdentifierSummary' {} Maybe Text
a -> ResourceIdentifierSummary
s {$sel:resourceType:ResourceIdentifierSummary' :: Maybe Text
resourceType = Maybe Text
a} :: ResourceIdentifierSummary)

-- | The logical IDs of the target resources of the specified @ResourceType@,
-- as defined in the import template.
resourceIdentifierSummary_logicalResourceIds :: Lens.Lens' ResourceIdentifierSummary (Prelude.Maybe (Prelude.NonEmpty Prelude.Text))
resourceIdentifierSummary_logicalResourceIds :: (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ResourceIdentifierSummary -> f ResourceIdentifierSummary
resourceIdentifierSummary_logicalResourceIds = (ResourceIdentifierSummary -> Maybe (NonEmpty Text))
-> (ResourceIdentifierSummary
    -> Maybe (NonEmpty Text) -> ResourceIdentifierSummary)
-> Lens
     ResourceIdentifierSummary
     ResourceIdentifierSummary
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceIdentifierSummary' {Maybe (NonEmpty Text)
logicalResourceIds :: Maybe (NonEmpty Text)
$sel:logicalResourceIds:ResourceIdentifierSummary' :: ResourceIdentifierSummary -> Maybe (NonEmpty Text)
logicalResourceIds} -> Maybe (NonEmpty Text)
logicalResourceIds) (\s :: ResourceIdentifierSummary
s@ResourceIdentifierSummary' {} Maybe (NonEmpty Text)
a -> ResourceIdentifierSummary
s {$sel:logicalResourceIds:ResourceIdentifierSummary' :: Maybe (NonEmpty Text)
logicalResourceIds = Maybe (NonEmpty Text)
a} :: ResourceIdentifierSummary) ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
 -> ResourceIdentifierSummary -> f ResourceIdentifierSummary)
-> ((Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
    -> Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> (Maybe (NonEmpty Text) -> f (Maybe (NonEmpty Text)))
-> ResourceIdentifierSummary
-> f ResourceIdentifierSummary
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
-> Iso
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty Text))
     (Maybe (NonEmpty 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
  (NonEmpty Text) (NonEmpty Text) (NonEmpty Text) (NonEmpty Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The resource properties you can provide during the import to identify
-- your target resources. For example, @BucketName@ is a possible
-- identifier property for @AWS::S3::Bucket@ resources.
resourceIdentifierSummary_resourceIdentifiers :: Lens.Lens' ResourceIdentifierSummary (Prelude.Maybe [Prelude.Text])
resourceIdentifierSummary_resourceIdentifiers :: (Maybe [Text] -> f (Maybe [Text]))
-> ResourceIdentifierSummary -> f ResourceIdentifierSummary
resourceIdentifierSummary_resourceIdentifiers = (ResourceIdentifierSummary -> Maybe [Text])
-> (ResourceIdentifierSummary
    -> Maybe [Text] -> ResourceIdentifierSummary)
-> Lens
     ResourceIdentifierSummary
     ResourceIdentifierSummary
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceIdentifierSummary' {Maybe [Text]
resourceIdentifiers :: Maybe [Text]
$sel:resourceIdentifiers:ResourceIdentifierSummary' :: ResourceIdentifierSummary -> Maybe [Text]
resourceIdentifiers} -> Maybe [Text]
resourceIdentifiers) (\s :: ResourceIdentifierSummary
s@ResourceIdentifierSummary' {} Maybe [Text]
a -> ResourceIdentifierSummary
s {$sel:resourceIdentifiers:ResourceIdentifierSummary' :: Maybe [Text]
resourceIdentifiers = Maybe [Text]
a} :: ResourceIdentifierSummary) ((Maybe [Text] -> f (Maybe [Text]))
 -> ResourceIdentifierSummary -> f ResourceIdentifierSummary)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ResourceIdentifierSummary
-> f ResourceIdentifierSummary
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

instance Core.FromXML ResourceIdentifierSummary where
  parseXML :: [Node] -> Either String ResourceIdentifierSummary
parseXML [Node]
x =
    Maybe Text
-> Maybe (NonEmpty Text)
-> Maybe [Text]
-> ResourceIdentifierSummary
ResourceIdentifierSummary'
      (Maybe Text
 -> Maybe (NonEmpty Text)
 -> Maybe [Text]
 -> ResourceIdentifierSummary)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe (NonEmpty Text)
      -> Maybe [Text] -> ResourceIdentifierSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResourceType")
      Either
  String
  (Maybe (NonEmpty Text)
   -> Maybe [Text] -> ResourceIdentifierSummary)
-> Either String (Maybe (NonEmpty Text))
-> Either String (Maybe [Text] -> ResourceIdentifierSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"LogicalResourceIds"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe (NonEmpty Text)))
-> Either String (Maybe (NonEmpty Text))
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String (NonEmpty Text))
-> [Node] -> Either String (Maybe (NonEmpty Text))
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String (NonEmpty Text)
forall a. FromXML a => Text -> [Node] -> Either String (NonEmpty a)
Core.parseXMLList1 Text
"member")
                  )
      Either String (Maybe [Text] -> ResourceIdentifierSummary)
-> Either String (Maybe [Text])
-> Either String ResourceIdentifierSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ResourceIdentifiers"
                      Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )

instance Prelude.Hashable ResourceIdentifierSummary

instance Prelude.NFData ResourceIdentifierSummary