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

import Amazonka.CodeDeploy.Types.Tag
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Information about an on-premises instance.
--
-- /See:/ 'newInstanceInfo' smart constructor.
data InstanceInfo = InstanceInfo'
  { -- | The time at which the on-premises instance was registered.
    InstanceInfo -> Maybe POSIX
registerTime :: Prelude.Maybe Core.POSIX,
    -- | The ARN of the on-premises instance.
    InstanceInfo -> Maybe Text
instanceArn :: Prelude.Maybe Prelude.Text,
    -- | If the on-premises instance was deregistered, the time at which the
    -- on-premises instance was deregistered.
    InstanceInfo -> Maybe POSIX
deregisterTime :: Prelude.Maybe Core.POSIX,
    -- | The IAM user ARN associated with the on-premises instance.
    InstanceInfo -> Maybe Text
iamUserArn :: Prelude.Maybe Prelude.Text,
    -- | The name of the on-premises instance.
    InstanceInfo -> Maybe Text
instanceName :: Prelude.Maybe Prelude.Text,
    -- | The ARN of the IAM session associated with the on-premises instance.
    InstanceInfo -> Maybe Text
iamSessionArn :: Prelude.Maybe Prelude.Text,
    -- | The tags currently associated with the on-premises instance.
    InstanceInfo -> Maybe [Tag]
tags :: Prelude.Maybe [Tag]
  }
  deriving (InstanceInfo -> InstanceInfo -> Bool
(InstanceInfo -> InstanceInfo -> Bool)
-> (InstanceInfo -> InstanceInfo -> Bool) -> Eq InstanceInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceInfo -> InstanceInfo -> Bool
$c/= :: InstanceInfo -> InstanceInfo -> Bool
== :: InstanceInfo -> InstanceInfo -> Bool
$c== :: InstanceInfo -> InstanceInfo -> Bool
Prelude.Eq, ReadPrec [InstanceInfo]
ReadPrec InstanceInfo
Int -> ReadS InstanceInfo
ReadS [InstanceInfo]
(Int -> ReadS InstanceInfo)
-> ReadS [InstanceInfo]
-> ReadPrec InstanceInfo
-> ReadPrec [InstanceInfo]
-> Read InstanceInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceInfo]
$creadListPrec :: ReadPrec [InstanceInfo]
readPrec :: ReadPrec InstanceInfo
$creadPrec :: ReadPrec InstanceInfo
readList :: ReadS [InstanceInfo]
$creadList :: ReadS [InstanceInfo]
readsPrec :: Int -> ReadS InstanceInfo
$creadsPrec :: Int -> ReadS InstanceInfo
Prelude.Read, Int -> InstanceInfo -> ShowS
[InstanceInfo] -> ShowS
InstanceInfo -> String
(Int -> InstanceInfo -> ShowS)
-> (InstanceInfo -> String)
-> ([InstanceInfo] -> ShowS)
-> Show InstanceInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceInfo] -> ShowS
$cshowList :: [InstanceInfo] -> ShowS
show :: InstanceInfo -> String
$cshow :: InstanceInfo -> String
showsPrec :: Int -> InstanceInfo -> ShowS
$cshowsPrec :: Int -> InstanceInfo -> ShowS
Prelude.Show, (forall x. InstanceInfo -> Rep InstanceInfo x)
-> (forall x. Rep InstanceInfo x -> InstanceInfo)
-> Generic InstanceInfo
forall x. Rep InstanceInfo x -> InstanceInfo
forall x. InstanceInfo -> Rep InstanceInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep InstanceInfo x -> InstanceInfo
$cfrom :: forall x. InstanceInfo -> Rep InstanceInfo x
Prelude.Generic)

-- |
-- Create a value of 'InstanceInfo' 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:
--
-- 'registerTime', 'instanceInfo_registerTime' - The time at which the on-premises instance was registered.
--
-- 'instanceArn', 'instanceInfo_instanceArn' - The ARN of the on-premises instance.
--
-- 'deregisterTime', 'instanceInfo_deregisterTime' - If the on-premises instance was deregistered, the time at which the
-- on-premises instance was deregistered.
--
-- 'iamUserArn', 'instanceInfo_iamUserArn' - The IAM user ARN associated with the on-premises instance.
--
-- 'instanceName', 'instanceInfo_instanceName' - The name of the on-premises instance.
--
-- 'iamSessionArn', 'instanceInfo_iamSessionArn' - The ARN of the IAM session associated with the on-premises instance.
--
-- 'tags', 'instanceInfo_tags' - The tags currently associated with the on-premises instance.
newInstanceInfo ::
  InstanceInfo
newInstanceInfo :: InstanceInfo
newInstanceInfo =
  InstanceInfo' :: Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> InstanceInfo
InstanceInfo'
    { $sel:registerTime:InstanceInfo' :: Maybe POSIX
registerTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceArn:InstanceInfo' :: Maybe Text
instanceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:deregisterTime:InstanceInfo' :: Maybe POSIX
deregisterTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:iamUserArn:InstanceInfo' :: Maybe Text
iamUserArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:instanceName:InstanceInfo' :: Maybe Text
instanceName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:iamSessionArn:InstanceInfo' :: Maybe Text
iamSessionArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:InstanceInfo' :: Maybe [Tag]
tags = Maybe [Tag]
forall a. Maybe a
Prelude.Nothing
    }

-- | The time at which the on-premises instance was registered.
instanceInfo_registerTime :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.UTCTime)
instanceInfo_registerTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceInfo -> f InstanceInfo
instanceInfo_registerTime = (InstanceInfo -> Maybe POSIX)
-> (InstanceInfo -> Maybe POSIX -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe POSIX
registerTime :: Maybe POSIX
$sel:registerTime:InstanceInfo' :: InstanceInfo -> Maybe POSIX
registerTime} -> Maybe POSIX
registerTime) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe POSIX
a -> InstanceInfo
s {$sel:registerTime:InstanceInfo' :: Maybe POSIX
registerTime = Maybe POSIX
a} :: InstanceInfo) ((Maybe POSIX -> f (Maybe POSIX))
 -> InstanceInfo -> f InstanceInfo)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceInfo
-> f InstanceInfo
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 ARN of the on-premises instance.
instanceInfo_instanceArn :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_instanceArn :: (Maybe Text -> f (Maybe Text)) -> InstanceInfo -> f InstanceInfo
instanceInfo_instanceArn = (InstanceInfo -> Maybe Text)
-> (InstanceInfo -> Maybe Text -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe Text
instanceArn :: Maybe Text
$sel:instanceArn:InstanceInfo' :: InstanceInfo -> Maybe Text
instanceArn} -> Maybe Text
instanceArn) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe Text
a -> InstanceInfo
s {$sel:instanceArn:InstanceInfo' :: Maybe Text
instanceArn = Maybe Text
a} :: InstanceInfo)

-- | If the on-premises instance was deregistered, the time at which the
-- on-premises instance was deregistered.
instanceInfo_deregisterTime :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.UTCTime)
instanceInfo_deregisterTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceInfo -> f InstanceInfo
instanceInfo_deregisterTime = (InstanceInfo -> Maybe POSIX)
-> (InstanceInfo -> Maybe POSIX -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe POSIX
deregisterTime :: Maybe POSIX
$sel:deregisterTime:InstanceInfo' :: InstanceInfo -> Maybe POSIX
deregisterTime} -> Maybe POSIX
deregisterTime) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe POSIX
a -> InstanceInfo
s {$sel:deregisterTime:InstanceInfo' :: Maybe POSIX
deregisterTime = Maybe POSIX
a} :: InstanceInfo) ((Maybe POSIX -> f (Maybe POSIX))
 -> InstanceInfo -> f InstanceInfo)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> InstanceInfo
-> f InstanceInfo
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 IAM user ARN associated with the on-premises instance.
instanceInfo_iamUserArn :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_iamUserArn :: (Maybe Text -> f (Maybe Text)) -> InstanceInfo -> f InstanceInfo
instanceInfo_iamUserArn = (InstanceInfo -> Maybe Text)
-> (InstanceInfo -> Maybe Text -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe Text
iamUserArn :: Maybe Text
$sel:iamUserArn:InstanceInfo' :: InstanceInfo -> Maybe Text
iamUserArn} -> Maybe Text
iamUserArn) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe Text
a -> InstanceInfo
s {$sel:iamUserArn:InstanceInfo' :: Maybe Text
iamUserArn = Maybe Text
a} :: InstanceInfo)

-- | The name of the on-premises instance.
instanceInfo_instanceName :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_instanceName :: (Maybe Text -> f (Maybe Text)) -> InstanceInfo -> f InstanceInfo
instanceInfo_instanceName = (InstanceInfo -> Maybe Text)
-> (InstanceInfo -> Maybe Text -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe Text
instanceName :: Maybe Text
$sel:instanceName:InstanceInfo' :: InstanceInfo -> Maybe Text
instanceName} -> Maybe Text
instanceName) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe Text
a -> InstanceInfo
s {$sel:instanceName:InstanceInfo' :: Maybe Text
instanceName = Maybe Text
a} :: InstanceInfo)

-- | The ARN of the IAM session associated with the on-premises instance.
instanceInfo_iamSessionArn :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_iamSessionArn :: (Maybe Text -> f (Maybe Text)) -> InstanceInfo -> f InstanceInfo
instanceInfo_iamSessionArn = (InstanceInfo -> Maybe Text)
-> (InstanceInfo -> Maybe Text -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe Text
iamSessionArn :: Maybe Text
$sel:iamSessionArn:InstanceInfo' :: InstanceInfo -> Maybe Text
iamSessionArn} -> Maybe Text
iamSessionArn) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe Text
a -> InstanceInfo
s {$sel:iamSessionArn:InstanceInfo' :: Maybe Text
iamSessionArn = Maybe Text
a} :: InstanceInfo)

-- | The tags currently associated with the on-premises instance.
instanceInfo_tags :: Lens.Lens' InstanceInfo (Prelude.Maybe [Tag])
instanceInfo_tags :: (Maybe [Tag] -> f (Maybe [Tag])) -> InstanceInfo -> f InstanceInfo
instanceInfo_tags = (InstanceInfo -> Maybe [Tag])
-> (InstanceInfo -> Maybe [Tag] -> InstanceInfo)
-> Lens InstanceInfo InstanceInfo (Maybe [Tag]) (Maybe [Tag])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceInfo' {Maybe [Tag]
tags :: Maybe [Tag]
$sel:tags:InstanceInfo' :: InstanceInfo -> Maybe [Tag]
tags} -> Maybe [Tag]
tags) (\s :: InstanceInfo
s@InstanceInfo' {} Maybe [Tag]
a -> InstanceInfo
s {$sel:tags:InstanceInfo' :: Maybe [Tag]
tags = Maybe [Tag]
a} :: InstanceInfo) ((Maybe [Tag] -> f (Maybe [Tag]))
 -> InstanceInfo -> f InstanceInfo)
-> ((Maybe [Tag] -> f (Maybe [Tag]))
    -> Maybe [Tag] -> f (Maybe [Tag]))
-> (Maybe [Tag] -> f (Maybe [Tag]))
-> InstanceInfo
-> f InstanceInfo
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Tag] [Tag] [Tag] [Tag]
-> Iso (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag]) (Maybe [Tag])
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 [Tag] [Tag] [Tag] [Tag]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON InstanceInfo where
  parseJSON :: Value -> Parser InstanceInfo
parseJSON =
    String
-> (Object -> Parser InstanceInfo) -> Value -> Parser InstanceInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceInfo"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text
-> Maybe POSIX
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe [Tag]
-> InstanceInfo
InstanceInfo'
            (Maybe POSIX
 -> Maybe Text
 -> Maybe POSIX
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe [Tag]
 -> InstanceInfo)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Tag]
      -> InstanceInfo)
forall (f :: * -> *) a b. Functor 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
"registerTime")
            Parser
  (Maybe Text
   -> Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Tag]
   -> InstanceInfo)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe [Tag]
      -> InstanceInfo)
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
"instanceArn")
            Parser
  (Maybe POSIX
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe [Tag]
   -> InstanceInfo)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe [Tag] -> InstanceInfo)
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
"deregisterTime")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe [Tag] -> InstanceInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe [Tag] -> InstanceInfo)
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
"iamUserArn")
            Parser (Maybe Text -> Maybe Text -> Maybe [Tag] -> InstanceInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe [Tag] -> InstanceInfo)
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
"instanceName")
            Parser (Maybe Text -> Maybe [Tag] -> InstanceInfo)
-> Parser (Maybe Text) -> Parser (Maybe [Tag] -> InstanceInfo)
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
"iamSessionArn")
            Parser (Maybe [Tag] -> InstanceInfo)
-> Parser (Maybe [Tag]) -> Parser InstanceInfo
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Tag]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"tags" Parser (Maybe (Maybe [Tag])) -> Maybe [Tag] -> Parser (Maybe [Tag])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Tag]
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable InstanceInfo

instance Prelude.NFData InstanceInfo