{-# 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.DataPipeline.Types.InstanceIdentity
-- 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.DataPipeline.Types.InstanceIdentity where

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

-- | Identity information for the EC2 instance that is hosting the task
-- runner. You can get this value by calling a metadata URI from the EC2
-- instance. For more information, see
-- <http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html Instance Metadata>
-- in the /Amazon Elastic Compute Cloud User Guide./ Passing in this value
-- proves that your task runner is running on an EC2 instance, and ensures
-- the proper AWS Data Pipeline service charges are applied to your
-- pipeline.
--
-- /See:/ 'newInstanceIdentity' smart constructor.
data InstanceIdentity = InstanceIdentity'
  { -- | A signature which can be used to verify the accuracy and authenticity of
    -- the information provided in the instance identity document.
    InstanceIdentity -> Maybe Text
signature :: Prelude.Maybe Prelude.Text,
    -- | A description of an EC2 instance that is generated when the instance is
    -- launched and exposed to the instance via the instance metadata service
    -- in the form of a JSON representation of an object.
    InstanceIdentity -> Maybe Text
document :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceIdentity -> InstanceIdentity -> Bool
(InstanceIdentity -> InstanceIdentity -> Bool)
-> (InstanceIdentity -> InstanceIdentity -> Bool)
-> Eq InstanceIdentity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceIdentity -> InstanceIdentity -> Bool
$c/= :: InstanceIdentity -> InstanceIdentity -> Bool
== :: InstanceIdentity -> InstanceIdentity -> Bool
$c== :: InstanceIdentity -> InstanceIdentity -> Bool
Prelude.Eq, ReadPrec [InstanceIdentity]
ReadPrec InstanceIdentity
Int -> ReadS InstanceIdentity
ReadS [InstanceIdentity]
(Int -> ReadS InstanceIdentity)
-> ReadS [InstanceIdentity]
-> ReadPrec InstanceIdentity
-> ReadPrec [InstanceIdentity]
-> Read InstanceIdentity
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceIdentity]
$creadListPrec :: ReadPrec [InstanceIdentity]
readPrec :: ReadPrec InstanceIdentity
$creadPrec :: ReadPrec InstanceIdentity
readList :: ReadS [InstanceIdentity]
$creadList :: ReadS [InstanceIdentity]
readsPrec :: Int -> ReadS InstanceIdentity
$creadsPrec :: Int -> ReadS InstanceIdentity
Prelude.Read, Int -> InstanceIdentity -> ShowS
[InstanceIdentity] -> ShowS
InstanceIdentity -> String
(Int -> InstanceIdentity -> ShowS)
-> (InstanceIdentity -> String)
-> ([InstanceIdentity] -> ShowS)
-> Show InstanceIdentity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceIdentity] -> ShowS
$cshowList :: [InstanceIdentity] -> ShowS
show :: InstanceIdentity -> String
$cshow :: InstanceIdentity -> String
showsPrec :: Int -> InstanceIdentity -> ShowS
$cshowsPrec :: Int -> InstanceIdentity -> ShowS
Prelude.Show, (forall x. InstanceIdentity -> Rep InstanceIdentity x)
-> (forall x. Rep InstanceIdentity x -> InstanceIdentity)
-> Generic InstanceIdentity
forall x. Rep InstanceIdentity x -> InstanceIdentity
forall x. InstanceIdentity -> Rep InstanceIdentity x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceIdentity x -> InstanceIdentity
$cfrom :: forall x. InstanceIdentity -> Rep InstanceIdentity x
Prelude.Generic)

-- |
-- Create a value of 'InstanceIdentity' 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:
--
-- 'signature', 'instanceIdentity_signature' - A signature which can be used to verify the accuracy and authenticity of
-- the information provided in the instance identity document.
--
-- 'document', 'instanceIdentity_document' - A description of an EC2 instance that is generated when the instance is
-- launched and exposed to the instance via the instance metadata service
-- in the form of a JSON representation of an object.
newInstanceIdentity ::
  InstanceIdentity
newInstanceIdentity :: InstanceIdentity
newInstanceIdentity =
  InstanceIdentity' :: Maybe Text -> Maybe Text -> InstanceIdentity
InstanceIdentity'
    { $sel:signature:InstanceIdentity' :: Maybe Text
signature = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:document:InstanceIdentity' :: Maybe Text
document = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A signature which can be used to verify the accuracy and authenticity of
-- the information provided in the instance identity document.
instanceIdentity_signature :: Lens.Lens' InstanceIdentity (Prelude.Maybe Prelude.Text)
instanceIdentity_signature :: (Maybe Text -> f (Maybe Text))
-> InstanceIdentity -> f InstanceIdentity
instanceIdentity_signature = (InstanceIdentity -> Maybe Text)
-> (InstanceIdentity -> Maybe Text -> InstanceIdentity)
-> Lens InstanceIdentity InstanceIdentity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceIdentity' {Maybe Text
signature :: Maybe Text
$sel:signature:InstanceIdentity' :: InstanceIdentity -> Maybe Text
signature} -> Maybe Text
signature) (\s :: InstanceIdentity
s@InstanceIdentity' {} Maybe Text
a -> InstanceIdentity
s {$sel:signature:InstanceIdentity' :: Maybe Text
signature = Maybe Text
a} :: InstanceIdentity)

-- | A description of an EC2 instance that is generated when the instance is
-- launched and exposed to the instance via the instance metadata service
-- in the form of a JSON representation of an object.
instanceIdentity_document :: Lens.Lens' InstanceIdentity (Prelude.Maybe Prelude.Text)
instanceIdentity_document :: (Maybe Text -> f (Maybe Text))
-> InstanceIdentity -> f InstanceIdentity
instanceIdentity_document = (InstanceIdentity -> Maybe Text)
-> (InstanceIdentity -> Maybe Text -> InstanceIdentity)
-> Lens InstanceIdentity InstanceIdentity (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceIdentity' {Maybe Text
document :: Maybe Text
$sel:document:InstanceIdentity' :: InstanceIdentity -> Maybe Text
document} -> Maybe Text
document) (\s :: InstanceIdentity
s@InstanceIdentity' {} Maybe Text
a -> InstanceIdentity
s {$sel:document:InstanceIdentity' :: Maybe Text
document = Maybe Text
a} :: InstanceIdentity)

instance Prelude.Hashable InstanceIdentity

instance Prelude.NFData InstanceIdentity

instance Core.ToJSON InstanceIdentity where
  toJSON :: InstanceIdentity -> Value
toJSON InstanceIdentity' {Maybe Text
document :: Maybe Text
signature :: Maybe Text
$sel:document:InstanceIdentity' :: InstanceIdentity -> Maybe Text
$sel:signature:InstanceIdentity' :: InstanceIdentity -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"signature" 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
signature,
            (Text
"document" 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
document
          ]
      )