{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

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

-- | 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 :: Lens' InstanceInfo (Maybe UTCTime)
instanceInfo_deregisterTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The ARN of the IAM session associated with the on-premises instance.
instanceInfo_iamSessionArn :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_iamSessionArn :: Lens' InstanceInfo (Maybe Text)
instanceInfo_iamSessionArn = 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 IAM user ARN associated with the on-premises instance.
instanceInfo_iamUserArn :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_iamUserArn :: Lens' InstanceInfo (Maybe Text)
instanceInfo_iamUserArn = 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 ARN of the on-premises instance.
instanceInfo_instanceArn :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_instanceArn :: Lens' InstanceInfo (Maybe Text)
instanceInfo_instanceArn = 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)

-- | The name of the on-premises instance.
instanceInfo_instanceName :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.Text)
instanceInfo_instanceName :: Lens' InstanceInfo (Maybe Text)
instanceInfo_instanceName = 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 time at which the on-premises instance was registered.
instanceInfo_registerTime :: Lens.Lens' InstanceInfo (Prelude.Maybe Prelude.UTCTime)
instanceInfo_registerTime :: Lens' InstanceInfo (Maybe UTCTime)
instanceInfo_registerTime = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

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

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

instance Prelude.Hashable InstanceInfo where
  hashWithSalt :: Int -> InstanceInfo -> Int
hashWithSalt Int
_salt InstanceInfo' {Maybe [Tag]
Maybe Text
Maybe POSIX
tags :: Maybe [Tag]
registerTime :: Maybe POSIX
instanceName :: Maybe Text
instanceArn :: Maybe Text
iamUserArn :: Maybe Text
iamSessionArn :: Maybe Text
deregisterTime :: Maybe POSIX
$sel:tags:InstanceInfo' :: InstanceInfo -> Maybe [Tag]
$sel:registerTime:InstanceInfo' :: InstanceInfo -> Maybe POSIX
$sel:instanceName:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:instanceArn:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:iamUserArn:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:iamSessionArn:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:deregisterTime:InstanceInfo' :: InstanceInfo -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
deregisterTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iamSessionArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
iamUserArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceArn
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
instanceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
registerTime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Tag]
tags

instance Prelude.NFData InstanceInfo where
  rnf :: InstanceInfo -> ()
rnf InstanceInfo' {Maybe [Tag]
Maybe Text
Maybe POSIX
tags :: Maybe [Tag]
registerTime :: Maybe POSIX
instanceName :: Maybe Text
instanceArn :: Maybe Text
iamUserArn :: Maybe Text
iamSessionArn :: Maybe Text
deregisterTime :: Maybe POSIX
$sel:tags:InstanceInfo' :: InstanceInfo -> Maybe [Tag]
$sel:registerTime:InstanceInfo' :: InstanceInfo -> Maybe POSIX
$sel:instanceName:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:instanceArn:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:iamUserArn:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:iamSessionArn:InstanceInfo' :: InstanceInfo -> Maybe Text
$sel:deregisterTime:InstanceInfo' :: InstanceInfo -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
deregisterTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iamSessionArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
iamUserArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
instanceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
registerTime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [Tag]
tags