{-# 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-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.ResourceToImport where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ResourceToImport -> ResourceToImport -> Bool)
-> (ResourceToImport -> ResourceToImport -> Bool)
-> Eq ResourceToImport
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]
(Int -> ReadS ResourceToImport)
-> ReadS [ResourceToImport]
-> ReadPrec ResourceToImport
-> ReadPrec [ResourceToImport]
-> Read 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
(Int -> ResourceToImport -> ShowS)
-> (ResourceToImport -> String)
-> ([ResourceToImport] -> ShowS)
-> Show ResourceToImport
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. ResourceToImport -> Rep ResourceToImport x)
-> (forall x. Rep ResourceToImport x -> ResourceToImport)
-> Generic ResourceToImport
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' :: Text -> Text -> HashMap Text Text -> ResourceToImport
ResourceToImport'
      { $sel:resourceType:ResourceToImport' :: Text
resourceType = Text
pResourceType_,
        $sel:logicalResourceId:ResourceToImport' :: Text
logicalResourceId = Text
pLogicalResourceId_,
        $sel:resourceIdentifier:ResourceToImport' :: HashMap Text Text
resourceIdentifier = HashMap Text Text
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 :: (Text -> f Text) -> ResourceToImport -> f ResourceToImport
resourceToImport_resourceType = (ResourceToImport -> Text)
-> (ResourceToImport -> Text -> ResourceToImport)
-> Lens ResourceToImport ResourceToImport Text Text
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 :: (Text -> f Text) -> ResourceToImport -> f ResourceToImport
resourceToImport_logicalResourceId = (ResourceToImport -> Text)
-> (ResourceToImport -> Text -> ResourceToImport)
-> Lens ResourceToImport ResourceToImport Text Text
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 :: (HashMap Text Text -> f (HashMap Text Text))
-> ResourceToImport -> f ResourceToImport
resourceToImport_resourceIdentifier = (ResourceToImport -> HashMap Text Text)
-> (ResourceToImport -> HashMap Text Text -> ResourceToImport)
-> Lens
     ResourceToImport
     ResourceToImport
     (HashMap Text Text)
     (HashMap Text Text)
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) ((HashMap Text Text -> f (HashMap Text Text))
 -> ResourceToImport -> f ResourceToImport)
-> ((HashMap Text Text -> f (HashMap Text Text))
    -> HashMap Text Text -> f (HashMap Text Text))
-> (HashMap Text Text -> f (HashMap Text Text))
-> ResourceToImport
-> f ResourceToImport
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (HashMap Text Text -> f (HashMap Text Text))
-> HashMap Text Text -> f (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable ResourceToImport

instance Prelude.NFData ResourceToImport

instance Core.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
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"ResourceType" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
resourceType,
        ByteString
"LogicalResourceId" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
logicalResourceId,
        ByteString
"ResourceIdentifier"
          ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: ByteString
-> ByteString -> ByteString -> HashMap Text Text -> QueryString
forall k v.
(ToQuery k, ToQuery v) =>
ByteString
-> ByteString -> ByteString -> HashMap k v -> QueryString
Core.toQueryMap
            ByteString
"entry"
            ByteString
"key"
            ByteString
"value"
            HashMap Text Text
resourceIdentifier
      ]