{-# 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.SecurityHub.Types.ContainerDetails
-- 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.SecurityHub.Types.ContainerDetails where

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

-- | Container details related to a finding.
--
-- /See:/ 'newContainerDetails' smart constructor.
data ContainerDetails = ContainerDetails'
  { -- | The name of the container related to a finding.
    ContainerDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The identifier of the image related to a finding.
    ContainerDetails -> Maybe Text
imageId :: Prelude.Maybe Prelude.Text,
    -- | The name of the image related to a finding.
    ContainerDetails -> Maybe Text
imageName :: Prelude.Maybe Prelude.Text,
    -- | Indicates when the container started.
    --
    -- Uses the @date-time@ format specified in
    -- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
    -- The value cannot contain spaces. For example,
    -- @2020-03-22T13:22:13.933Z@.
    ContainerDetails -> Maybe Text
launchedAt :: Prelude.Maybe Prelude.Text
  }
  deriving (ContainerDetails -> ContainerDetails -> Bool
(ContainerDetails -> ContainerDetails -> Bool)
-> (ContainerDetails -> ContainerDetails -> Bool)
-> Eq ContainerDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ContainerDetails -> ContainerDetails -> Bool
$c/= :: ContainerDetails -> ContainerDetails -> Bool
== :: ContainerDetails -> ContainerDetails -> Bool
$c== :: ContainerDetails -> ContainerDetails -> Bool
Prelude.Eq, ReadPrec [ContainerDetails]
ReadPrec ContainerDetails
Int -> ReadS ContainerDetails
ReadS [ContainerDetails]
(Int -> ReadS ContainerDetails)
-> ReadS [ContainerDetails]
-> ReadPrec ContainerDetails
-> ReadPrec [ContainerDetails]
-> Read ContainerDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ContainerDetails]
$creadListPrec :: ReadPrec [ContainerDetails]
readPrec :: ReadPrec ContainerDetails
$creadPrec :: ReadPrec ContainerDetails
readList :: ReadS [ContainerDetails]
$creadList :: ReadS [ContainerDetails]
readsPrec :: Int -> ReadS ContainerDetails
$creadsPrec :: Int -> ReadS ContainerDetails
Prelude.Read, Int -> ContainerDetails -> ShowS
[ContainerDetails] -> ShowS
ContainerDetails -> String
(Int -> ContainerDetails -> ShowS)
-> (ContainerDetails -> String)
-> ([ContainerDetails] -> ShowS)
-> Show ContainerDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ContainerDetails] -> ShowS
$cshowList :: [ContainerDetails] -> ShowS
show :: ContainerDetails -> String
$cshow :: ContainerDetails -> String
showsPrec :: Int -> ContainerDetails -> ShowS
$cshowsPrec :: Int -> ContainerDetails -> ShowS
Prelude.Show, (forall x. ContainerDetails -> Rep ContainerDetails x)
-> (forall x. Rep ContainerDetails x -> ContainerDetails)
-> Generic ContainerDetails
forall x. Rep ContainerDetails x -> ContainerDetails
forall x. ContainerDetails -> Rep ContainerDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ContainerDetails x -> ContainerDetails
$cfrom :: forall x. ContainerDetails -> Rep ContainerDetails x
Prelude.Generic)

-- |
-- Create a value of 'ContainerDetails' 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:
--
-- 'name', 'containerDetails_name' - The name of the container related to a finding.
--
-- 'imageId', 'containerDetails_imageId' - The identifier of the image related to a finding.
--
-- 'imageName', 'containerDetails_imageName' - The name of the image related to a finding.
--
-- 'launchedAt', 'containerDetails_launchedAt' - Indicates when the container started.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
newContainerDetails ::
  ContainerDetails
newContainerDetails :: ContainerDetails
newContainerDetails =
  ContainerDetails' :: Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> ContainerDetails
ContainerDetails'
    { $sel:name:ContainerDetails' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageId:ContainerDetails' :: Maybe Text
imageId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:imageName:ContainerDetails' :: Maybe Text
imageName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:launchedAt:ContainerDetails' :: Maybe Text
launchedAt = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the container related to a finding.
containerDetails_name :: Lens.Lens' ContainerDetails (Prelude.Maybe Prelude.Text)
containerDetails_name :: (Maybe Text -> f (Maybe Text))
-> ContainerDetails -> f ContainerDetails
containerDetails_name = (ContainerDetails -> Maybe Text)
-> (ContainerDetails -> Maybe Text -> ContainerDetails)
-> Lens ContainerDetails ContainerDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDetails' {Maybe Text
name :: Maybe Text
$sel:name:ContainerDetails' :: ContainerDetails -> Maybe Text
name} -> Maybe Text
name) (\s :: ContainerDetails
s@ContainerDetails' {} Maybe Text
a -> ContainerDetails
s {$sel:name:ContainerDetails' :: Maybe Text
name = Maybe Text
a} :: ContainerDetails)

-- | The identifier of the image related to a finding.
containerDetails_imageId :: Lens.Lens' ContainerDetails (Prelude.Maybe Prelude.Text)
containerDetails_imageId :: (Maybe Text -> f (Maybe Text))
-> ContainerDetails -> f ContainerDetails
containerDetails_imageId = (ContainerDetails -> Maybe Text)
-> (ContainerDetails -> Maybe Text -> ContainerDetails)
-> Lens ContainerDetails ContainerDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDetails' {Maybe Text
imageId :: Maybe Text
$sel:imageId:ContainerDetails' :: ContainerDetails -> Maybe Text
imageId} -> Maybe Text
imageId) (\s :: ContainerDetails
s@ContainerDetails' {} Maybe Text
a -> ContainerDetails
s {$sel:imageId:ContainerDetails' :: Maybe Text
imageId = Maybe Text
a} :: ContainerDetails)

-- | The name of the image related to a finding.
containerDetails_imageName :: Lens.Lens' ContainerDetails (Prelude.Maybe Prelude.Text)
containerDetails_imageName :: (Maybe Text -> f (Maybe Text))
-> ContainerDetails -> f ContainerDetails
containerDetails_imageName = (ContainerDetails -> Maybe Text)
-> (ContainerDetails -> Maybe Text -> ContainerDetails)
-> Lens ContainerDetails ContainerDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDetails' {Maybe Text
imageName :: Maybe Text
$sel:imageName:ContainerDetails' :: ContainerDetails -> Maybe Text
imageName} -> Maybe Text
imageName) (\s :: ContainerDetails
s@ContainerDetails' {} Maybe Text
a -> ContainerDetails
s {$sel:imageName:ContainerDetails' :: Maybe Text
imageName = Maybe Text
a} :: ContainerDetails)

-- | Indicates when the container started.
--
-- Uses the @date-time@ format specified in
-- <https://tools.ietf.org/html/rfc3339#section-5.6 RFC 3339 section 5.6, Internet Date\/Time Format>.
-- The value cannot contain spaces. For example,
-- @2020-03-22T13:22:13.933Z@.
containerDetails_launchedAt :: Lens.Lens' ContainerDetails (Prelude.Maybe Prelude.Text)
containerDetails_launchedAt :: (Maybe Text -> f (Maybe Text))
-> ContainerDetails -> f ContainerDetails
containerDetails_launchedAt = (ContainerDetails -> Maybe Text)
-> (ContainerDetails -> Maybe Text -> ContainerDetails)
-> Lens ContainerDetails ContainerDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ContainerDetails' {Maybe Text
launchedAt :: Maybe Text
$sel:launchedAt:ContainerDetails' :: ContainerDetails -> Maybe Text
launchedAt} -> Maybe Text
launchedAt) (\s :: ContainerDetails
s@ContainerDetails' {} Maybe Text
a -> ContainerDetails
s {$sel:launchedAt:ContainerDetails' :: Maybe Text
launchedAt = Maybe Text
a} :: ContainerDetails)

instance Core.FromJSON ContainerDetails where
  parseJSON :: Value -> Parser ContainerDetails
parseJSON =
    String
-> (Object -> Parser ContainerDetails)
-> Value
-> Parser ContainerDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ContainerDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Text -> ContainerDetails
ContainerDetails'
            (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> ContainerDetails)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> ContainerDetails)
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
"Name")
            Parser (Maybe Text -> Maybe Text -> Maybe Text -> ContainerDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> ContainerDetails)
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
"ImageId")
            Parser (Maybe Text -> Maybe Text -> ContainerDetails)
-> Parser (Maybe Text) -> Parser (Maybe Text -> ContainerDetails)
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
"ImageName")
            Parser (Maybe Text -> ContainerDetails)
-> Parser (Maybe Text) -> Parser ContainerDetails
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
"LaunchedAt")
      )

instance Prelude.Hashable ContainerDetails

instance Prelude.NFData ContainerDetails

instance Core.ToJSON ContainerDetails where
  toJSON :: ContainerDetails -> Value
toJSON ContainerDetails' {Maybe Text
launchedAt :: Maybe Text
imageName :: Maybe Text
imageId :: Maybe Text
name :: Maybe Text
$sel:launchedAt:ContainerDetails' :: ContainerDetails -> Maybe Text
$sel:imageName:ContainerDetails' :: ContainerDetails -> Maybe Text
$sel:imageId:ContainerDetails' :: ContainerDetails -> Maybe Text
$sel:name:ContainerDetails' :: ContainerDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Name" 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
name,
            (Text
"ImageId" 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
imageId,
            (Text
"ImageName" 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
imageName,
            (Text
"LaunchedAt" 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
launchedAt
          ]
      )