{-# 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.Batch.Types.AttemptContainerDetail
-- 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.Batch.Types.AttemptContainerDetail where

import Amazonka.Batch.Types.NetworkInterface
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing the details of a container that\'s part of a job
-- attempt.
--
-- /See:/ 'newAttemptContainerDetail' smart constructor.
data AttemptContainerDetail = AttemptContainerDetail'
  { -- | The network interfaces associated with the job attempt.
    AttemptContainerDetail -> Maybe [NetworkInterface]
networkInterfaces :: Prelude.Maybe [NetworkInterface],
    -- | The Amazon Resource Name (ARN) of the Amazon ECS task that\'s associated
    -- with the job attempt. Each container attempt receives a task ARN when
    -- they reach the @STARTING@ status.
    AttemptContainerDetail -> Maybe Text
taskArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the Amazon ECS container instance that
    -- hosts the job attempt.
    AttemptContainerDetail -> Maybe Text
containerInstanceArn :: Prelude.Maybe Prelude.Text,
    -- | A short (255 max characters) human-readable string to provide additional
    -- details about a running or stopped container.
    AttemptContainerDetail -> Maybe Text
reason :: Prelude.Maybe Prelude.Text,
    -- | The name of the CloudWatch Logs log stream associated with the
    -- container. The log group for Batch jobs is @\/aws\/batch\/job@. Each
    -- container attempt receives a log stream name when they reach the
    -- @RUNNING@ status.
    AttemptContainerDetail -> Maybe Text
logStreamName :: Prelude.Maybe Prelude.Text,
    -- | The exit code for the job attempt. A non-zero exit code is considered a
    -- failure.
    AttemptContainerDetail -> Maybe Int
exitCode :: Prelude.Maybe Prelude.Int
  }
  deriving (AttemptContainerDetail -> AttemptContainerDetail -> Bool
(AttemptContainerDetail -> AttemptContainerDetail -> Bool)
-> (AttemptContainerDetail -> AttemptContainerDetail -> Bool)
-> Eq AttemptContainerDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttemptContainerDetail -> AttemptContainerDetail -> Bool
$c/= :: AttemptContainerDetail -> AttemptContainerDetail -> Bool
== :: AttemptContainerDetail -> AttemptContainerDetail -> Bool
$c== :: AttemptContainerDetail -> AttemptContainerDetail -> Bool
Prelude.Eq, ReadPrec [AttemptContainerDetail]
ReadPrec AttemptContainerDetail
Int -> ReadS AttemptContainerDetail
ReadS [AttemptContainerDetail]
(Int -> ReadS AttemptContainerDetail)
-> ReadS [AttemptContainerDetail]
-> ReadPrec AttemptContainerDetail
-> ReadPrec [AttemptContainerDetail]
-> Read AttemptContainerDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttemptContainerDetail]
$creadListPrec :: ReadPrec [AttemptContainerDetail]
readPrec :: ReadPrec AttemptContainerDetail
$creadPrec :: ReadPrec AttemptContainerDetail
readList :: ReadS [AttemptContainerDetail]
$creadList :: ReadS [AttemptContainerDetail]
readsPrec :: Int -> ReadS AttemptContainerDetail
$creadsPrec :: Int -> ReadS AttemptContainerDetail
Prelude.Read, Int -> AttemptContainerDetail -> ShowS
[AttemptContainerDetail] -> ShowS
AttemptContainerDetail -> String
(Int -> AttemptContainerDetail -> ShowS)
-> (AttemptContainerDetail -> String)
-> ([AttemptContainerDetail] -> ShowS)
-> Show AttemptContainerDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttemptContainerDetail] -> ShowS
$cshowList :: [AttemptContainerDetail] -> ShowS
show :: AttemptContainerDetail -> String
$cshow :: AttemptContainerDetail -> String
showsPrec :: Int -> AttemptContainerDetail -> ShowS
$cshowsPrec :: Int -> AttemptContainerDetail -> ShowS
Prelude.Show, (forall x. AttemptContainerDetail -> Rep AttemptContainerDetail x)
-> (forall x.
    Rep AttemptContainerDetail x -> AttemptContainerDetail)
-> Generic AttemptContainerDetail
forall x. Rep AttemptContainerDetail x -> AttemptContainerDetail
forall x. AttemptContainerDetail -> Rep AttemptContainerDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttemptContainerDetail x -> AttemptContainerDetail
$cfrom :: forall x. AttemptContainerDetail -> Rep AttemptContainerDetail x
Prelude.Generic)

-- |
-- Create a value of 'AttemptContainerDetail' 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:
--
-- 'networkInterfaces', 'attemptContainerDetail_networkInterfaces' - The network interfaces associated with the job attempt.
--
-- 'taskArn', 'attemptContainerDetail_taskArn' - The Amazon Resource Name (ARN) of the Amazon ECS task that\'s associated
-- with the job attempt. Each container attempt receives a task ARN when
-- they reach the @STARTING@ status.
--
-- 'containerInstanceArn', 'attemptContainerDetail_containerInstanceArn' - The Amazon Resource Name (ARN) of the Amazon ECS container instance that
-- hosts the job attempt.
--
-- 'reason', 'attemptContainerDetail_reason' - A short (255 max characters) human-readable string to provide additional
-- details about a running or stopped container.
--
-- 'logStreamName', 'attemptContainerDetail_logStreamName' - The name of the CloudWatch Logs log stream associated with the
-- container. The log group for Batch jobs is @\/aws\/batch\/job@. Each
-- container attempt receives a log stream name when they reach the
-- @RUNNING@ status.
--
-- 'exitCode', 'attemptContainerDetail_exitCode' - The exit code for the job attempt. A non-zero exit code is considered a
-- failure.
newAttemptContainerDetail ::
  AttemptContainerDetail
newAttemptContainerDetail :: AttemptContainerDetail
newAttemptContainerDetail =
  AttemptContainerDetail' :: Maybe [NetworkInterface]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> AttemptContainerDetail
AttemptContainerDetail'
    { $sel:networkInterfaces:AttemptContainerDetail' :: Maybe [NetworkInterface]
networkInterfaces =
        Maybe [NetworkInterface]
forall a. Maybe a
Prelude.Nothing,
      $sel:taskArn:AttemptContainerDetail' :: Maybe Text
taskArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:containerInstanceArn:AttemptContainerDetail' :: Maybe Text
containerInstanceArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:reason:AttemptContainerDetail' :: Maybe Text
reason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:logStreamName:AttemptContainerDetail' :: Maybe Text
logStreamName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:exitCode:AttemptContainerDetail' :: Maybe Int
exitCode = Maybe Int
forall a. Maybe a
Prelude.Nothing
    }

-- | The network interfaces associated with the job attempt.
attemptContainerDetail_networkInterfaces :: Lens.Lens' AttemptContainerDetail (Prelude.Maybe [NetworkInterface])
attemptContainerDetail_networkInterfaces :: (Maybe [NetworkInterface] -> f (Maybe [NetworkInterface]))
-> AttemptContainerDetail -> f AttemptContainerDetail
attemptContainerDetail_networkInterfaces = (AttemptContainerDetail -> Maybe [NetworkInterface])
-> (AttemptContainerDetail
    -> Maybe [NetworkInterface] -> AttemptContainerDetail)
-> Lens
     AttemptContainerDetail
     AttemptContainerDetail
     (Maybe [NetworkInterface])
     (Maybe [NetworkInterface])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptContainerDetail' {Maybe [NetworkInterface]
networkInterfaces :: Maybe [NetworkInterface]
$sel:networkInterfaces:AttemptContainerDetail' :: AttemptContainerDetail -> Maybe [NetworkInterface]
networkInterfaces} -> Maybe [NetworkInterface]
networkInterfaces) (\s :: AttemptContainerDetail
s@AttemptContainerDetail' {} Maybe [NetworkInterface]
a -> AttemptContainerDetail
s {$sel:networkInterfaces:AttemptContainerDetail' :: Maybe [NetworkInterface]
networkInterfaces = Maybe [NetworkInterface]
a} :: AttemptContainerDetail) ((Maybe [NetworkInterface] -> f (Maybe [NetworkInterface]))
 -> AttemptContainerDetail -> f AttemptContainerDetail)
-> ((Maybe [NetworkInterface] -> f (Maybe [NetworkInterface]))
    -> Maybe [NetworkInterface] -> f (Maybe [NetworkInterface]))
-> (Maybe [NetworkInterface] -> f (Maybe [NetworkInterface]))
-> AttemptContainerDetail
-> f AttemptContainerDetail
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [NetworkInterface]
  [NetworkInterface]
  [NetworkInterface]
  [NetworkInterface]
-> Iso
     (Maybe [NetworkInterface])
     (Maybe [NetworkInterface])
     (Maybe [NetworkInterface])
     (Maybe [NetworkInterface])
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
  [NetworkInterface]
  [NetworkInterface]
  [NetworkInterface]
  [NetworkInterface]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) of the Amazon ECS task that\'s associated
-- with the job attempt. Each container attempt receives a task ARN when
-- they reach the @STARTING@ status.
attemptContainerDetail_taskArn :: Lens.Lens' AttemptContainerDetail (Prelude.Maybe Prelude.Text)
attemptContainerDetail_taskArn :: (Maybe Text -> f (Maybe Text))
-> AttemptContainerDetail -> f AttemptContainerDetail
attemptContainerDetail_taskArn = (AttemptContainerDetail -> Maybe Text)
-> (AttemptContainerDetail -> Maybe Text -> AttemptContainerDetail)
-> Lens
     AttemptContainerDetail
     AttemptContainerDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptContainerDetail' {Maybe Text
taskArn :: Maybe Text
$sel:taskArn:AttemptContainerDetail' :: AttemptContainerDetail -> Maybe Text
taskArn} -> Maybe Text
taskArn) (\s :: AttemptContainerDetail
s@AttemptContainerDetail' {} Maybe Text
a -> AttemptContainerDetail
s {$sel:taskArn:AttemptContainerDetail' :: Maybe Text
taskArn = Maybe Text
a} :: AttemptContainerDetail)

-- | The Amazon Resource Name (ARN) of the Amazon ECS container instance that
-- hosts the job attempt.
attemptContainerDetail_containerInstanceArn :: Lens.Lens' AttemptContainerDetail (Prelude.Maybe Prelude.Text)
attemptContainerDetail_containerInstanceArn :: (Maybe Text -> f (Maybe Text))
-> AttemptContainerDetail -> f AttemptContainerDetail
attemptContainerDetail_containerInstanceArn = (AttemptContainerDetail -> Maybe Text)
-> (AttemptContainerDetail -> Maybe Text -> AttemptContainerDetail)
-> Lens
     AttemptContainerDetail
     AttemptContainerDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptContainerDetail' {Maybe Text
containerInstanceArn :: Maybe Text
$sel:containerInstanceArn:AttemptContainerDetail' :: AttemptContainerDetail -> Maybe Text
containerInstanceArn} -> Maybe Text
containerInstanceArn) (\s :: AttemptContainerDetail
s@AttemptContainerDetail' {} Maybe Text
a -> AttemptContainerDetail
s {$sel:containerInstanceArn:AttemptContainerDetail' :: Maybe Text
containerInstanceArn = Maybe Text
a} :: AttemptContainerDetail)

-- | A short (255 max characters) human-readable string to provide additional
-- details about a running or stopped container.
attemptContainerDetail_reason :: Lens.Lens' AttemptContainerDetail (Prelude.Maybe Prelude.Text)
attemptContainerDetail_reason :: (Maybe Text -> f (Maybe Text))
-> AttemptContainerDetail -> f AttemptContainerDetail
attemptContainerDetail_reason = (AttemptContainerDetail -> Maybe Text)
-> (AttemptContainerDetail -> Maybe Text -> AttemptContainerDetail)
-> Lens
     AttemptContainerDetail
     AttemptContainerDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptContainerDetail' {Maybe Text
reason :: Maybe Text
$sel:reason:AttemptContainerDetail' :: AttemptContainerDetail -> Maybe Text
reason} -> Maybe Text
reason) (\s :: AttemptContainerDetail
s@AttemptContainerDetail' {} Maybe Text
a -> AttemptContainerDetail
s {$sel:reason:AttemptContainerDetail' :: Maybe Text
reason = Maybe Text
a} :: AttemptContainerDetail)

-- | The name of the CloudWatch Logs log stream associated with the
-- container. The log group for Batch jobs is @\/aws\/batch\/job@. Each
-- container attempt receives a log stream name when they reach the
-- @RUNNING@ status.
attemptContainerDetail_logStreamName :: Lens.Lens' AttemptContainerDetail (Prelude.Maybe Prelude.Text)
attemptContainerDetail_logStreamName :: (Maybe Text -> f (Maybe Text))
-> AttemptContainerDetail -> f AttemptContainerDetail
attemptContainerDetail_logStreamName = (AttemptContainerDetail -> Maybe Text)
-> (AttemptContainerDetail -> Maybe Text -> AttemptContainerDetail)
-> Lens
     AttemptContainerDetail
     AttemptContainerDetail
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptContainerDetail' {Maybe Text
logStreamName :: Maybe Text
$sel:logStreamName:AttemptContainerDetail' :: AttemptContainerDetail -> Maybe Text
logStreamName} -> Maybe Text
logStreamName) (\s :: AttemptContainerDetail
s@AttemptContainerDetail' {} Maybe Text
a -> AttemptContainerDetail
s {$sel:logStreamName:AttemptContainerDetail' :: Maybe Text
logStreamName = Maybe Text
a} :: AttemptContainerDetail)

-- | The exit code for the job attempt. A non-zero exit code is considered a
-- failure.
attemptContainerDetail_exitCode :: Lens.Lens' AttemptContainerDetail (Prelude.Maybe Prelude.Int)
attemptContainerDetail_exitCode :: (Maybe Int -> f (Maybe Int))
-> AttemptContainerDetail -> f AttemptContainerDetail
attemptContainerDetail_exitCode = (AttemptContainerDetail -> Maybe Int)
-> (AttemptContainerDetail -> Maybe Int -> AttemptContainerDetail)
-> Lens
     AttemptContainerDetail
     AttemptContainerDetail
     (Maybe Int)
     (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptContainerDetail' {Maybe Int
exitCode :: Maybe Int
$sel:exitCode:AttemptContainerDetail' :: AttemptContainerDetail -> Maybe Int
exitCode} -> Maybe Int
exitCode) (\s :: AttemptContainerDetail
s@AttemptContainerDetail' {} Maybe Int
a -> AttemptContainerDetail
s {$sel:exitCode:AttemptContainerDetail' :: Maybe Int
exitCode = Maybe Int
a} :: AttemptContainerDetail)

instance Core.FromJSON AttemptContainerDetail where
  parseJSON :: Value -> Parser AttemptContainerDetail
parseJSON =
    String
-> (Object -> Parser AttemptContainerDetail)
-> Value
-> Parser AttemptContainerDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttemptContainerDetail"
      ( \Object
x ->
          Maybe [NetworkInterface]
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Int
-> AttemptContainerDetail
AttemptContainerDetail'
            (Maybe [NetworkInterface]
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Int
 -> AttemptContainerDetail)
-> Parser (Maybe [NetworkInterface])
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Int
      -> AttemptContainerDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [NetworkInterface]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"networkInterfaces"
                            Parser (Maybe (Maybe [NetworkInterface]))
-> Maybe [NetworkInterface] -> Parser (Maybe [NetworkInterface])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [NetworkInterface]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Int
   -> AttemptContainerDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Int -> AttemptContainerDetail)
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
"taskArn")
            Parser
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Int -> AttemptContainerDetail)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Int -> AttemptContainerDetail)
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
"containerInstanceArn")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Int -> AttemptContainerDetail)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Int -> AttemptContainerDetail)
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
"reason")
            Parser (Maybe Text -> Maybe Int -> AttemptContainerDetail)
-> Parser (Maybe Text)
-> Parser (Maybe Int -> AttemptContainerDetail)
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
"logStreamName")
            Parser (Maybe Int -> AttemptContainerDetail)
-> Parser (Maybe Int) -> Parser AttemptContainerDetail
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"exitCode")
      )

instance Prelude.Hashable AttemptContainerDetail

instance Prelude.NFData AttemptContainerDetail