{-# 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.CodeDeploy.Types.InstanceTarget
-- 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.CodeDeploy.Types.InstanceTarget where

import Amazonka.CodeDeploy.Types.LifecycleEvent
import Amazonka.CodeDeploy.Types.TargetLabel
import Amazonka.CodeDeploy.Types.TargetStatus
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A target Amazon EC2 or on-premises instance during a deployment that
-- uses the EC2\/On-premises compute platform.
--
-- /See:/ 'newInstanceTarget' smart constructor.
data InstanceTarget = InstanceTarget'
  { -- | The Amazon Resource Name (ARN) of the target.
    InstanceTarget -> Maybe Text
targetArn :: Prelude.Maybe Prelude.Text,
    -- | The unique ID of a deployment target that has a type of
    -- @instanceTarget@.
    InstanceTarget -> Maybe Text
targetId :: Prelude.Maybe Prelude.Text,
    -- | The status an EC2\/On-premises deployment\'s target instance.
    InstanceTarget -> Maybe TargetStatus
status :: Prelude.Maybe TargetStatus,
    -- | The unique ID of a deployment.
    InstanceTarget -> Maybe Text
deploymentId :: Prelude.Maybe Prelude.Text,
    -- | A label that identifies whether the instance is an original target
    -- (@BLUE@) or a replacement target (@GREEN@).
    InstanceTarget -> Maybe TargetLabel
instanceLabel :: Prelude.Maybe TargetLabel,
    -- | The date and time when the target instance was updated by a deployment.
    InstanceTarget -> Maybe POSIX
lastUpdatedAt :: Prelude.Maybe Core.POSIX,
    -- | The lifecycle events of the deployment to this target instance.
    InstanceTarget -> Maybe [LifecycleEvent]
lifecycleEvents :: Prelude.Maybe [LifecycleEvent]
  }
  deriving (InstanceTarget -> InstanceTarget -> Bool
(InstanceTarget -> InstanceTarget -> Bool)
-> (InstanceTarget -> InstanceTarget -> Bool) -> Eq InstanceTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceTarget -> InstanceTarget -> Bool
$c/= :: InstanceTarget -> InstanceTarget -> Bool
== :: InstanceTarget -> InstanceTarget -> Bool
$c== :: InstanceTarget -> InstanceTarget -> Bool
Prelude.Eq, ReadPrec [InstanceTarget]
ReadPrec InstanceTarget
Int -> ReadS InstanceTarget
ReadS [InstanceTarget]
(Int -> ReadS InstanceTarget)
-> ReadS [InstanceTarget]
-> ReadPrec InstanceTarget
-> ReadPrec [InstanceTarget]
-> Read InstanceTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceTarget]
$creadListPrec :: ReadPrec [InstanceTarget]
readPrec :: ReadPrec InstanceTarget
$creadPrec :: ReadPrec InstanceTarget
readList :: ReadS [InstanceTarget]
$creadList :: ReadS [InstanceTarget]
readsPrec :: Int -> ReadS InstanceTarget
$creadsPrec :: Int -> ReadS InstanceTarget
Prelude.Read, Int -> InstanceTarget -> ShowS
[InstanceTarget] -> ShowS
InstanceTarget -> String
(Int -> InstanceTarget -> ShowS)
-> (InstanceTarget -> String)
-> ([InstanceTarget] -> ShowS)
-> Show InstanceTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceTarget] -> ShowS
$cshowList :: [InstanceTarget] -> ShowS
show :: InstanceTarget -> String
$cshow :: InstanceTarget -> String
showsPrec :: Int -> InstanceTarget -> ShowS
$cshowsPrec :: Int -> InstanceTarget -> ShowS
Prelude.Show, (forall x. InstanceTarget -> Rep InstanceTarget x)
-> (forall x. Rep InstanceTarget x -> InstanceTarget)
-> Generic InstanceTarget
forall x. Rep InstanceTarget x -> InstanceTarget
forall x. InstanceTarget -> Rep InstanceTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceTarget x -> InstanceTarget
$cfrom :: forall x. InstanceTarget -> Rep InstanceTarget x
Prelude.Generic)

-- |
-- Create a value of 'InstanceTarget' 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:
--
-- 'targetArn', 'instanceTarget_targetArn' - The Amazon Resource Name (ARN) of the target.
--
-- 'targetId', 'instanceTarget_targetId' - The unique ID of a deployment target that has a type of
-- @instanceTarget@.
--
-- 'status', 'instanceTarget_status' - The status an EC2\/On-premises deployment\'s target instance.
--
-- 'deploymentId', 'instanceTarget_deploymentId' - The unique ID of a deployment.
--
-- 'instanceLabel', 'instanceTarget_instanceLabel' - A label that identifies whether the instance is an original target
-- (@BLUE@) or a replacement target (@GREEN@).
--
-- 'lastUpdatedAt', 'instanceTarget_lastUpdatedAt' - The date and time when the target instance was updated by a deployment.
--
-- 'lifecycleEvents', 'instanceTarget_lifecycleEvents' - The lifecycle events of the deployment to this target instance.
newInstanceTarget ::
  InstanceTarget
newInstanceTarget :: InstanceTarget
newInstanceTarget =
  InstanceTarget' :: Maybe Text
-> Maybe Text
-> Maybe TargetStatus
-> Maybe Text
-> Maybe TargetLabel
-> Maybe POSIX
-> Maybe [LifecycleEvent]
-> InstanceTarget
InstanceTarget'
    { $sel:targetArn:InstanceTarget' :: Maybe Text
targetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:targetId:InstanceTarget' :: Maybe Text
targetId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:status:InstanceTarget' :: Maybe TargetStatus
status = Maybe TargetStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:deploymentId:InstanceTarget' :: Maybe Text
deploymentId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceLabel:InstanceTarget' :: Maybe TargetLabel
instanceLabel = Maybe TargetLabel
forall a. Maybe a
Prelude.Nothing,
      $sel:lastUpdatedAt:InstanceTarget' :: Maybe POSIX
lastUpdatedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:lifecycleEvents:InstanceTarget' :: Maybe [LifecycleEvent]
lifecycleEvents = Maybe [LifecycleEvent]
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) of the target.
instanceTarget_targetArn :: Lens.Lens' InstanceTarget (Prelude.Maybe Prelude.Text)
instanceTarget_targetArn :: (Maybe Text -> f (Maybe Text))
-> InstanceTarget -> f InstanceTarget
instanceTarget_targetArn = (InstanceTarget -> Maybe Text)
-> (InstanceTarget -> Maybe Text -> InstanceTarget)
-> Lens InstanceTarget InstanceTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe Text
targetArn :: Maybe Text
$sel:targetArn:InstanceTarget' :: InstanceTarget -> Maybe Text
targetArn} -> Maybe Text
targetArn) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe Text
a -> InstanceTarget
s {$sel:targetArn:InstanceTarget' :: Maybe Text
targetArn = Maybe Text
a} :: InstanceTarget)

-- | The unique ID of a deployment target that has a type of
-- @instanceTarget@.
instanceTarget_targetId :: Lens.Lens' InstanceTarget (Prelude.Maybe Prelude.Text)
instanceTarget_targetId :: (Maybe Text -> f (Maybe Text))
-> InstanceTarget -> f InstanceTarget
instanceTarget_targetId = (InstanceTarget -> Maybe Text)
-> (InstanceTarget -> Maybe Text -> InstanceTarget)
-> Lens InstanceTarget InstanceTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe Text
targetId :: Maybe Text
$sel:targetId:InstanceTarget' :: InstanceTarget -> Maybe Text
targetId} -> Maybe Text
targetId) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe Text
a -> InstanceTarget
s {$sel:targetId:InstanceTarget' :: Maybe Text
targetId = Maybe Text
a} :: InstanceTarget)

-- | The status an EC2\/On-premises deployment\'s target instance.
instanceTarget_status :: Lens.Lens' InstanceTarget (Prelude.Maybe TargetStatus)
instanceTarget_status :: (Maybe TargetStatus -> f (Maybe TargetStatus))
-> InstanceTarget -> f InstanceTarget
instanceTarget_status = (InstanceTarget -> Maybe TargetStatus)
-> (InstanceTarget -> Maybe TargetStatus -> InstanceTarget)
-> Lens
     InstanceTarget
     InstanceTarget
     (Maybe TargetStatus)
     (Maybe TargetStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe TargetStatus
status :: Maybe TargetStatus
$sel:status:InstanceTarget' :: InstanceTarget -> Maybe TargetStatus
status} -> Maybe TargetStatus
status) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe TargetStatus
a -> InstanceTarget
s {$sel:status:InstanceTarget' :: Maybe TargetStatus
status = Maybe TargetStatus
a} :: InstanceTarget)

-- | The unique ID of a deployment.
instanceTarget_deploymentId :: Lens.Lens' InstanceTarget (Prelude.Maybe Prelude.Text)
instanceTarget_deploymentId :: (Maybe Text -> f (Maybe Text))
-> InstanceTarget -> f InstanceTarget
instanceTarget_deploymentId = (InstanceTarget -> Maybe Text)
-> (InstanceTarget -> Maybe Text -> InstanceTarget)
-> Lens InstanceTarget InstanceTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe Text
deploymentId :: Maybe Text
$sel:deploymentId:InstanceTarget' :: InstanceTarget -> Maybe Text
deploymentId} -> Maybe Text
deploymentId) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe Text
a -> InstanceTarget
s {$sel:deploymentId:InstanceTarget' :: Maybe Text
deploymentId = Maybe Text
a} :: InstanceTarget)

-- | A label that identifies whether the instance is an original target
-- (@BLUE@) or a replacement target (@GREEN@).
instanceTarget_instanceLabel :: Lens.Lens' InstanceTarget (Prelude.Maybe TargetLabel)
instanceTarget_instanceLabel :: (Maybe TargetLabel -> f (Maybe TargetLabel))
-> InstanceTarget -> f InstanceTarget
instanceTarget_instanceLabel = (InstanceTarget -> Maybe TargetLabel)
-> (InstanceTarget -> Maybe TargetLabel -> InstanceTarget)
-> Lens
     InstanceTarget
     InstanceTarget
     (Maybe TargetLabel)
     (Maybe TargetLabel)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe TargetLabel
instanceLabel :: Maybe TargetLabel
$sel:instanceLabel:InstanceTarget' :: InstanceTarget -> Maybe TargetLabel
instanceLabel} -> Maybe TargetLabel
instanceLabel) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe TargetLabel
a -> InstanceTarget
s {$sel:instanceLabel:InstanceTarget' :: Maybe TargetLabel
instanceLabel = Maybe TargetLabel
a} :: InstanceTarget)

-- | The date and time when the target instance was updated by a deployment.
instanceTarget_lastUpdatedAt :: Lens.Lens' InstanceTarget (Prelude.Maybe Prelude.UTCTime)
instanceTarget_lastUpdatedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTarget -> f InstanceTarget
instanceTarget_lastUpdatedAt = (InstanceTarget -> Maybe POSIX)
-> (InstanceTarget -> Maybe POSIX -> InstanceTarget)
-> Lens InstanceTarget InstanceTarget (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe POSIX
lastUpdatedAt :: Maybe POSIX
$sel:lastUpdatedAt:InstanceTarget' :: InstanceTarget -> Maybe POSIX
lastUpdatedAt} -> Maybe POSIX
lastUpdatedAt) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe POSIX
a -> InstanceTarget
s {$sel:lastUpdatedAt:InstanceTarget' :: Maybe POSIX
lastUpdatedAt = Maybe POSIX
a} :: InstanceTarget) ((Maybe POSIX -> f (Maybe POSIX))
 -> InstanceTarget -> f InstanceTarget)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceTarget
-> f InstanceTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The lifecycle events of the deployment to this target instance.
instanceTarget_lifecycleEvents :: Lens.Lens' InstanceTarget (Prelude.Maybe [LifecycleEvent])
instanceTarget_lifecycleEvents :: (Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
-> InstanceTarget -> f InstanceTarget
instanceTarget_lifecycleEvents = (InstanceTarget -> Maybe [LifecycleEvent])
-> (InstanceTarget -> Maybe [LifecycleEvent] -> InstanceTarget)
-> Lens
     InstanceTarget
     InstanceTarget
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceTarget' {Maybe [LifecycleEvent]
lifecycleEvents :: Maybe [LifecycleEvent]
$sel:lifecycleEvents:InstanceTarget' :: InstanceTarget -> Maybe [LifecycleEvent]
lifecycleEvents} -> Maybe [LifecycleEvent]
lifecycleEvents) (\s :: InstanceTarget
s@InstanceTarget' {} Maybe [LifecycleEvent]
a -> InstanceTarget
s {$sel:lifecycleEvents:InstanceTarget' :: Maybe [LifecycleEvent]
lifecycleEvents = Maybe [LifecycleEvent]
a} :: InstanceTarget) ((Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
 -> InstanceTarget -> f InstanceTarget)
-> ((Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
    -> Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
-> (Maybe [LifecycleEvent] -> f (Maybe [LifecycleEvent]))
-> InstanceTarget
-> f InstanceTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [LifecycleEvent] [LifecycleEvent] [LifecycleEvent] [LifecycleEvent]
-> Iso
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
     (Maybe [LifecycleEvent])
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
  [LifecycleEvent] [LifecycleEvent] [LifecycleEvent] [LifecycleEvent]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON InstanceTarget where
  parseJSON :: Value -> Parser InstanceTarget
parseJSON =
    String
-> (Object -> Parser InstanceTarget)
-> Value
-> Parser InstanceTarget
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceTarget"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe TargetStatus
-> Maybe Text
-> Maybe TargetLabel
-> Maybe POSIX
-> Maybe [LifecycleEvent]
-> InstanceTarget
InstanceTarget'
            (Maybe Text
 -> Maybe Text
 -> Maybe TargetStatus
 -> Maybe Text
 -> Maybe TargetLabel
 -> Maybe POSIX
 -> Maybe [LifecycleEvent]
 -> InstanceTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe TargetStatus
      -> Maybe Text
      -> Maybe TargetLabel
      -> Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> InstanceTarget)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetArn")
            Parser
  (Maybe Text
   -> Maybe TargetStatus
   -> Maybe Text
   -> Maybe TargetLabel
   -> Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> InstanceTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe TargetStatus
      -> Maybe Text
      -> Maybe TargetLabel
      -> Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> InstanceTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"targetId")
            Parser
  (Maybe TargetStatus
   -> Maybe Text
   -> Maybe TargetLabel
   -> Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> InstanceTarget)
-> Parser (Maybe TargetStatus)
-> Parser
     (Maybe Text
      -> Maybe TargetLabel
      -> Maybe POSIX
      -> Maybe [LifecycleEvent]
      -> InstanceTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TargetStatus)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"status")
            Parser
  (Maybe Text
   -> Maybe TargetLabel
   -> Maybe POSIX
   -> Maybe [LifecycleEvent]
   -> InstanceTarget)
-> Parser (Maybe Text)
-> Parser
     (Maybe TargetLabel
      -> Maybe POSIX -> Maybe [LifecycleEvent] -> InstanceTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"deploymentId")
            Parser
  (Maybe TargetLabel
   -> Maybe POSIX -> Maybe [LifecycleEvent] -> InstanceTarget)
-> Parser (Maybe TargetLabel)
-> Parser (Maybe POSIX -> Maybe [LifecycleEvent] -> InstanceTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe TargetLabel)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"instanceLabel")
            Parser (Maybe POSIX -> Maybe [LifecycleEvent] -> InstanceTarget)
-> Parser (Maybe POSIX)
-> Parser (Maybe [LifecycleEvent] -> InstanceTarget)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lastUpdatedAt")
            Parser (Maybe [LifecycleEvent] -> InstanceTarget)
-> Parser (Maybe [LifecycleEvent]) -> Parser InstanceTarget
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [LifecycleEvent]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"lifecycleEvents"
                            Parser (Maybe (Maybe [LifecycleEvent]))
-> Maybe [LifecycleEvent] -> Parser (Maybe [LifecycleEvent])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [LifecycleEvent]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable InstanceTarget

instance Prelude.NFData InstanceTarget