{-# 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.ECS.Types.VersionInfo
-- 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.ECS.Types.VersionInfo where

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

-- | The Docker and Amazon ECS container agent version information about a
-- container instance.
--
-- /See:/ 'newVersionInfo' smart constructor.
data VersionInfo = VersionInfo'
  { -- | The Git commit hash for the Amazon ECS container agent build on the
    -- <https://github.com/aws/amazon-ecs-agent/commits/master amazon-ecs-agent>
    -- GitHub repository.
    VersionInfo -> Maybe Text
agentHash :: Prelude.Maybe Prelude.Text,
    -- | The version number of the Amazon ECS container agent.
    VersionInfo -> Maybe Text
agentVersion :: Prelude.Maybe Prelude.Text,
    -- | The Docker version running on the container instance.
    VersionInfo -> Maybe Text
dockerVersion :: Prelude.Maybe Prelude.Text
  }
  deriving (VersionInfo -> VersionInfo -> Bool
(VersionInfo -> VersionInfo -> Bool)
-> (VersionInfo -> VersionInfo -> Bool) -> Eq VersionInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VersionInfo -> VersionInfo -> Bool
$c/= :: VersionInfo -> VersionInfo -> Bool
== :: VersionInfo -> VersionInfo -> Bool
$c== :: VersionInfo -> VersionInfo -> Bool
Prelude.Eq, ReadPrec [VersionInfo]
ReadPrec VersionInfo
Int -> ReadS VersionInfo
ReadS [VersionInfo]
(Int -> ReadS VersionInfo)
-> ReadS [VersionInfo]
-> ReadPrec VersionInfo
-> ReadPrec [VersionInfo]
-> Read VersionInfo
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VersionInfo]
$creadListPrec :: ReadPrec [VersionInfo]
readPrec :: ReadPrec VersionInfo
$creadPrec :: ReadPrec VersionInfo
readList :: ReadS [VersionInfo]
$creadList :: ReadS [VersionInfo]
readsPrec :: Int -> ReadS VersionInfo
$creadsPrec :: Int -> ReadS VersionInfo
Prelude.Read, Int -> VersionInfo -> ShowS
[VersionInfo] -> ShowS
VersionInfo -> String
(Int -> VersionInfo -> ShowS)
-> (VersionInfo -> String)
-> ([VersionInfo] -> ShowS)
-> Show VersionInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VersionInfo] -> ShowS
$cshowList :: [VersionInfo] -> ShowS
show :: VersionInfo -> String
$cshow :: VersionInfo -> String
showsPrec :: Int -> VersionInfo -> ShowS
$cshowsPrec :: Int -> VersionInfo -> ShowS
Prelude.Show, (forall x. VersionInfo -> Rep VersionInfo x)
-> (forall x. Rep VersionInfo x -> VersionInfo)
-> Generic VersionInfo
forall x. Rep VersionInfo x -> VersionInfo
forall x. VersionInfo -> Rep VersionInfo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VersionInfo x -> VersionInfo
$cfrom :: forall x. VersionInfo -> Rep VersionInfo x
Prelude.Generic)

-- |
-- Create a value of 'VersionInfo' 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:
--
-- 'agentHash', 'versionInfo_agentHash' - The Git commit hash for the Amazon ECS container agent build on the
-- <https://github.com/aws/amazon-ecs-agent/commits/master amazon-ecs-agent>
-- GitHub repository.
--
-- 'agentVersion', 'versionInfo_agentVersion' - The version number of the Amazon ECS container agent.
--
-- 'dockerVersion', 'versionInfo_dockerVersion' - The Docker version running on the container instance.
newVersionInfo ::
  VersionInfo
newVersionInfo :: VersionInfo
newVersionInfo =
  VersionInfo' :: Maybe Text -> Maybe Text -> Maybe Text -> VersionInfo
VersionInfo'
    { $sel:agentHash:VersionInfo' :: Maybe Text
agentHash = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:agentVersion:VersionInfo' :: Maybe Text
agentVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dockerVersion:VersionInfo' :: Maybe Text
dockerVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Git commit hash for the Amazon ECS container agent build on the
-- <https://github.com/aws/amazon-ecs-agent/commits/master amazon-ecs-agent>
-- GitHub repository.
versionInfo_agentHash :: Lens.Lens' VersionInfo (Prelude.Maybe Prelude.Text)
versionInfo_agentHash :: (Maybe Text -> f (Maybe Text)) -> VersionInfo -> f VersionInfo
versionInfo_agentHash = (VersionInfo -> Maybe Text)
-> (VersionInfo -> Maybe Text -> VersionInfo)
-> Lens VersionInfo VersionInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersionInfo' {Maybe Text
agentHash :: Maybe Text
$sel:agentHash:VersionInfo' :: VersionInfo -> Maybe Text
agentHash} -> Maybe Text
agentHash) (\s :: VersionInfo
s@VersionInfo' {} Maybe Text
a -> VersionInfo
s {$sel:agentHash:VersionInfo' :: Maybe Text
agentHash = Maybe Text
a} :: VersionInfo)

-- | The version number of the Amazon ECS container agent.
versionInfo_agentVersion :: Lens.Lens' VersionInfo (Prelude.Maybe Prelude.Text)
versionInfo_agentVersion :: (Maybe Text -> f (Maybe Text)) -> VersionInfo -> f VersionInfo
versionInfo_agentVersion = (VersionInfo -> Maybe Text)
-> (VersionInfo -> Maybe Text -> VersionInfo)
-> Lens VersionInfo VersionInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersionInfo' {Maybe Text
agentVersion :: Maybe Text
$sel:agentVersion:VersionInfo' :: VersionInfo -> Maybe Text
agentVersion} -> Maybe Text
agentVersion) (\s :: VersionInfo
s@VersionInfo' {} Maybe Text
a -> VersionInfo
s {$sel:agentVersion:VersionInfo' :: Maybe Text
agentVersion = Maybe Text
a} :: VersionInfo)

-- | The Docker version running on the container instance.
versionInfo_dockerVersion :: Lens.Lens' VersionInfo (Prelude.Maybe Prelude.Text)
versionInfo_dockerVersion :: (Maybe Text -> f (Maybe Text)) -> VersionInfo -> f VersionInfo
versionInfo_dockerVersion = (VersionInfo -> Maybe Text)
-> (VersionInfo -> Maybe Text -> VersionInfo)
-> Lens VersionInfo VersionInfo (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VersionInfo' {Maybe Text
dockerVersion :: Maybe Text
$sel:dockerVersion:VersionInfo' :: VersionInfo -> Maybe Text
dockerVersion} -> Maybe Text
dockerVersion) (\s :: VersionInfo
s@VersionInfo' {} Maybe Text
a -> VersionInfo
s {$sel:dockerVersion:VersionInfo' :: Maybe Text
dockerVersion = Maybe Text
a} :: VersionInfo)

instance Core.FromJSON VersionInfo where
  parseJSON :: Value -> Parser VersionInfo
parseJSON =
    String
-> (Object -> Parser VersionInfo) -> Value -> Parser VersionInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VersionInfo"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> VersionInfo
VersionInfo'
            (Maybe Text -> Maybe Text -> Maybe Text -> VersionInfo)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> VersionInfo)
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
"agentHash")
            Parser (Maybe Text -> Maybe Text -> VersionInfo)
-> Parser (Maybe Text) -> Parser (Maybe Text -> VersionInfo)
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
"agentVersion")
            Parser (Maybe Text -> VersionInfo)
-> Parser (Maybe Text) -> Parser VersionInfo
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
"dockerVersion")
      )

instance Prelude.Hashable VersionInfo

instance Prelude.NFData VersionInfo

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