{-# 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.ResourceToImport
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.CloudFormation.Types.ResourceToImport 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

-- | Describes the target resource of an import operation.
--
-- /See:/ 'newResourceToImport' smart constructor.
data ResourceToImport = ResourceToImport'
  { -- | The type of resource to import into your stack, such as
    -- @AWS::S3::Bucket@. For a list of supported resource types, see
    -- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html Resources that support import operations>
    -- in the CloudFormation User Guide.
    ResourceToImport -> Text
resourceType :: Prelude.Text,
    -- | The logical ID of the target resource as specified in the template.
    ResourceToImport -> Text
logicalResourceId :: Prelude.Text,
    -- | A key-value pair that identifies the target resource. The key is an
    -- identifier property (for example, @BucketName@ for @AWS::S3::Bucket@
    -- resources) and the value is the actual property value (for example,
    -- @MyS3Bucket@).
    ResourceToImport -> HashMap Text Text
resourceIdentifier :: Prelude.HashMap Prelude.Text Prelude.Text
  }
  deriving (ResourceToImport -> ResourceToImport -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResourceToImport -> ResourceToImport -> Bool
$c/= :: ResourceToImport -> ResourceToImport -> Bool
== :: ResourceToImport -> ResourceToImport -> Bool
$c== :: ResourceToImport -> ResourceToImport -> Bool
Prelude.Eq, ReadPrec [ResourceToImport]
ReadPrec ResourceToImport
Int -> ReadS ResourceToImport
ReadS [ResourceToImport]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResourceToImport]
$creadListPrec :: ReadPrec [ResourceToImport]
readPrec :: ReadPrec ResourceToImport
$creadPrec :: ReadPrec ResourceToImport
readList :: ReadS [ResourceToImport]
$creadList :: ReadS [ResourceToImport]
readsPrec :: Int -> ReadS ResourceToImport
$creadsPrec :: Int -> ReadS ResourceToImport
Prelude.Read, Int -> ResourceToImport -> ShowS
[ResourceToImport] -> ShowS
ResourceToImport -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResourceToImport] -> ShowS
$cshowList :: [ResourceToImport] -> ShowS
show :: ResourceToImport -> String
$cshow :: ResourceToImport -> String
showsPrec :: Int -> ResourceToImport -> ShowS
$cshowsPrec :: Int -> ResourceToImport -> ShowS
Prelude.Show, forall x. Rep ResourceToImport x -> ResourceToImport
forall x. ResourceToImport -> Rep ResourceToImport x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResourceToImport x -> ResourceToImport
$cfrom :: forall x. ResourceToImport -> Rep ResourceToImport x
Prelude.Generic)

-- |
-- Create a value of 'ResourceToImport' 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', 'resourceToImport_resourceType' - The type of resource to import into your stack, such as
-- @AWS::S3::Bucket@. For a list of supported resource types, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html Resources that support import operations>
-- in the CloudFormation User Guide.
--
-- 'logicalResourceId', 'resourceToImport_logicalResourceId' - The logical ID of the target resource as specified in the template.
--
-- 'resourceIdentifier', 'resourceToImport_resourceIdentifier' - A key-value pair that identifies the target resource. The key is an
-- identifier property (for example, @BucketName@ for @AWS::S3::Bucket@
-- resources) and the value is the actual property value (for example,
-- @MyS3Bucket@).
newResourceToImport ::
  -- | 'resourceType'
  Prelude.Text ->
  -- | 'logicalResourceId'
  Prelude.Text ->
  ResourceToImport
newResourceToImport :: Text -> Text -> ResourceToImport
newResourceToImport
  Text
pResourceType_
  Text
pLogicalResourceId_ =
    ResourceToImport'
      { $sel:resourceType:ResourceToImport' :: Text
resourceType = Text
pResourceType_,
        $sel:logicalResourceId:ResourceToImport' :: Text
logicalResourceId = Text
pLogicalResourceId_,
        $sel:resourceIdentifier:ResourceToImport' :: HashMap Text Text
resourceIdentifier = forall a. Monoid a => a
Prelude.mempty
      }

-- | The type of resource to import into your stack, such as
-- @AWS::S3::Bucket@. For a list of supported resource types, see
-- <https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/resource-import-supported-resources.html Resources that support import operations>
-- in the CloudFormation User Guide.
resourceToImport_resourceType :: Lens.Lens' ResourceToImport Prelude.Text
resourceToImport_resourceType :: Lens' ResourceToImport Text
resourceToImport_resourceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceToImport' {Text
resourceType :: Text
$sel:resourceType:ResourceToImport' :: ResourceToImport -> Text
resourceType} -> Text
resourceType) (\s :: ResourceToImport
s@ResourceToImport' {} Text
a -> ResourceToImport
s {$sel:resourceType:ResourceToImport' :: Text
resourceType = Text
a} :: ResourceToImport)

-- | The logical ID of the target resource as specified in the template.
resourceToImport_logicalResourceId :: Lens.Lens' ResourceToImport Prelude.Text
resourceToImport_logicalResourceId :: Lens' ResourceToImport Text
resourceToImport_logicalResourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceToImport' {Text
logicalResourceId :: Text
$sel:logicalResourceId:ResourceToImport' :: ResourceToImport -> Text
logicalResourceId} -> Text
logicalResourceId) (\s :: ResourceToImport
s@ResourceToImport' {} Text
a -> ResourceToImport
s {$sel:logicalResourceId:ResourceToImport' :: Text
logicalResourceId = Text
a} :: ResourceToImport)

-- | A key-value pair that identifies the target resource. The key is an
-- identifier property (for example, @BucketName@ for @AWS::S3::Bucket@
-- resources) and the value is the actual property value (for example,
-- @MyS3Bucket@).
resourceToImport_resourceIdentifier :: Lens.Lens' ResourceToImport (Prelude.HashMap Prelude.Text Prelude.Text)
resourceToImport_resourceIdentifier :: Lens' ResourceToImport (HashMap Text Text)
resourceToImport_resourceIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ResourceToImport' {HashMap Text Text
resourceIdentifier :: HashMap Text Text
$sel:resourceIdentifier:ResourceToImport' :: ResourceToImport -> HashMap Text Text
resourceIdentifier} -> HashMap Text Text
resourceIdentifier) (\s :: ResourceToImport
s@ResourceToImport' {} HashMap Text Text
a -> ResourceToImport
s {$sel:resourceIdentifier:ResourceToImport' :: HashMap Text Text
resourceIdentifier = HashMap Text Text
a} :: ResourceToImport) 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.Hashable ResourceToImport where
  hashWithSalt :: Int -> ResourceToImport -> Int
hashWithSalt Int
_salt ResourceToImport' {Text
HashMap Text Text
resourceIdentifier :: HashMap Text Text
logicalResourceId :: Text
resourceType :: Text
$sel:resourceIdentifier:ResourceToImport' :: ResourceToImport -> HashMap Text Text
$sel:logicalResourceId:ResourceToImport' :: ResourceToImport -> Text
$sel:resourceType:ResourceToImport' :: ResourceToImport -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
logicalResourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HashMap Text Text
resourceIdentifier

instance Prelude.NFData ResourceToImport where
  rnf :: ResourceToImport -> ()
rnf ResourceToImport' {Text
HashMap Text Text
resourceIdentifier :: HashMap Text Text
logicalResourceId :: Text
resourceType :: Text
$sel:resourceIdentifier:ResourceToImport' :: ResourceToImport -> HashMap Text Text
$sel:logicalResourceId:ResourceToImport' :: ResourceToImport -> Text
$sel:resourceType:ResourceToImport' :: ResourceToImport -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
logicalResourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HashMap Text Text
resourceIdentifier

instance Data.ToQuery ResourceToImport where
  toQuery :: ResourceToImport -> QueryString
toQuery ResourceToImport' {Text
HashMap Text Text
resourceIdentifier :: HashMap Text Text
logicalResourceId :: Text
resourceType :: Text
$sel:resourceIdentifier:ResourceToImport' :: ResourceToImport -> HashMap Text Text
$sel:logicalResourceId:ResourceToImport' :: ResourceToImport -> Text
$sel:resourceType:ResourceToImport' :: ResourceToImport -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ResourceType" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
resourceType,
        ByteString
"LogicalResourceId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
logicalResourceId,
        ByteString
"ResourceIdentifier"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Data.toQueryMap
            ByteString
"entry"
            ByteString
"key"
            ByteString
"value"
            HashMap Text Text
resourceIdentifier
      ]