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

-- | 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 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,
    -- | 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
  }
  deriving (InstanceIdentity -> InstanceIdentity -> Bool
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]
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
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. 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:
--
-- '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.
--
-- 'signature', 'instanceIdentity_signature' - A signature which can be used to verify the accuracy and authenticity of
-- the information provided in the instance identity document.
newInstanceIdentity ::
  InstanceIdentity
newInstanceIdentity :: InstanceIdentity
newInstanceIdentity =
  InstanceIdentity'
    { $sel:document:InstanceIdentity' :: Maybe Text
document = forall a. Maybe a
Prelude.Nothing,
      $sel:signature:InstanceIdentity' :: Maybe Text
signature = forall a. Maybe a
Prelude.Nothing
    }

-- | 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 :: Lens' InstanceIdentity (Maybe Text)
instanceIdentity_document = 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)

-- | 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 :: Lens' InstanceIdentity (Maybe Text)
instanceIdentity_signature = 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)

instance Prelude.Hashable InstanceIdentity where
  hashWithSalt :: Int -> InstanceIdentity -> Int
hashWithSalt Int
_salt InstanceIdentity' {Maybe Text
signature :: Maybe Text
document :: Maybe Text
$sel:signature:InstanceIdentity' :: InstanceIdentity -> Maybe Text
$sel:document:InstanceIdentity' :: InstanceIdentity -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
document
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
signature

instance Prelude.NFData InstanceIdentity where
  rnf :: InstanceIdentity -> ()
rnf InstanceIdentity' {Maybe Text
signature :: Maybe Text
document :: Maybe Text
$sel:signature:InstanceIdentity' :: InstanceIdentity -> Maybe Text
$sel:document:InstanceIdentity' :: InstanceIdentity -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
document
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
signature

instance Data.ToJSON InstanceIdentity where
  toJSON :: InstanceIdentity -> Value
toJSON InstanceIdentity' {Maybe Text
signature :: Maybe Text
document :: Maybe Text
$sel:signature:InstanceIdentity' :: InstanceIdentity -> Maybe Text
$sel:document:InstanceIdentity' :: InstanceIdentity -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"document" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
document,
            (Key
"signature" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
signature
          ]
      )