{-# 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.GuardDuty.Types.Container
-- 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.GuardDuty.Types.Container where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.GuardDuty.Types.SecurityContext
import Amazonka.GuardDuty.Types.VolumeMount
import qualified Amazonka.Prelude as Prelude

-- | Details of a container.
--
-- /See:/ 'newContainer' smart constructor.
data Container = Container'
  { -- | The container runtime (such as, Docker or containerd) used to run the
    -- container.
    Container -> Maybe Text
containerRuntime :: Prelude.Maybe Prelude.Text,
    -- | Container ID.
    Container -> Maybe Text
id :: Prelude.Maybe Prelude.Text,
    -- | Container image.
    Container -> Maybe Text
image :: Prelude.Maybe Prelude.Text,
    -- | Part of the image name before the last slash. For example, imagePrefix
    -- for public.ecr.aws\/amazonlinux\/amazonlinux:latest would be
    -- public.ecr.aws\/amazonlinux. If the image name is relative and does not
    -- have a slash, this field is empty.
    Container -> Maybe Text
imagePrefix :: Prelude.Maybe Prelude.Text,
    -- | Container name.
    Container -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | Container security context.
    Container -> Maybe SecurityContext
securityContext :: Prelude.Maybe SecurityContext,
    -- | Container volume mounts.
    Container -> Maybe [VolumeMount]
volumeMounts :: Prelude.Maybe [VolumeMount]
  }
  deriving (Container -> Container -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Container -> Container -> Bool
$c/= :: Container -> Container -> Bool
== :: Container -> Container -> Bool
$c== :: Container -> Container -> Bool
Prelude.Eq, ReadPrec [Container]
ReadPrec Container
Int -> ReadS Container
ReadS [Container]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Container]
$creadListPrec :: ReadPrec [Container]
readPrec :: ReadPrec Container
$creadPrec :: ReadPrec Container
readList :: ReadS [Container]
$creadList :: ReadS [Container]
readsPrec :: Int -> ReadS Container
$creadsPrec :: Int -> ReadS Container
Prelude.Read, Int -> Container -> ShowS
[Container] -> ShowS
Container -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Container] -> ShowS
$cshowList :: [Container] -> ShowS
show :: Container -> String
$cshow :: Container -> String
showsPrec :: Int -> Container -> ShowS
$cshowsPrec :: Int -> Container -> ShowS
Prelude.Show, forall x. Rep Container x -> Container
forall x. Container -> Rep Container x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Container x -> Container
$cfrom :: forall x. Container -> Rep Container x
Prelude.Generic)

-- |
-- Create a value of 'Container' 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:
--
-- 'containerRuntime', 'container_containerRuntime' - The container runtime (such as, Docker or containerd) used to run the
-- container.
--
-- 'id', 'container_id' - Container ID.
--
-- 'image', 'container_image' - Container image.
--
-- 'imagePrefix', 'container_imagePrefix' - Part of the image name before the last slash. For example, imagePrefix
-- for public.ecr.aws\/amazonlinux\/amazonlinux:latest would be
-- public.ecr.aws\/amazonlinux. If the image name is relative and does not
-- have a slash, this field is empty.
--
-- 'name', 'container_name' - Container name.
--
-- 'securityContext', 'container_securityContext' - Container security context.
--
-- 'volumeMounts', 'container_volumeMounts' - Container volume mounts.
newContainer ::
  Container
newContainer :: Container
newContainer =
  Container'
    { $sel:containerRuntime:Container' :: Maybe Text
containerRuntime = forall a. Maybe a
Prelude.Nothing,
      $sel:id:Container' :: Maybe Text
id = forall a. Maybe a
Prelude.Nothing,
      $sel:image:Container' :: Maybe Text
image = forall a. Maybe a
Prelude.Nothing,
      $sel:imagePrefix:Container' :: Maybe Text
imagePrefix = forall a. Maybe a
Prelude.Nothing,
      $sel:name:Container' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:securityContext:Container' :: Maybe SecurityContext
securityContext = forall a. Maybe a
Prelude.Nothing,
      $sel:volumeMounts:Container' :: Maybe [VolumeMount]
volumeMounts = forall a. Maybe a
Prelude.Nothing
    }

-- | The container runtime (such as, Docker or containerd) used to run the
-- container.
container_containerRuntime :: Lens.Lens' Container (Prelude.Maybe Prelude.Text)
container_containerRuntime :: Lens' Container (Maybe Text)
container_containerRuntime = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe Text
containerRuntime :: Maybe Text
$sel:containerRuntime:Container' :: Container -> Maybe Text
containerRuntime} -> Maybe Text
containerRuntime) (\s :: Container
s@Container' {} Maybe Text
a -> Container
s {$sel:containerRuntime:Container' :: Maybe Text
containerRuntime = Maybe Text
a} :: Container)

-- | Container ID.
container_id :: Lens.Lens' Container (Prelude.Maybe Prelude.Text)
container_id :: Lens' Container (Maybe Text)
container_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe Text
id :: Maybe Text
$sel:id:Container' :: Container -> Maybe Text
id} -> Maybe Text
id) (\s :: Container
s@Container' {} Maybe Text
a -> Container
s {$sel:id:Container' :: Maybe Text
id = Maybe Text
a} :: Container)

-- | Container image.
container_image :: Lens.Lens' Container (Prelude.Maybe Prelude.Text)
container_image :: Lens' Container (Maybe Text)
container_image = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe Text
image :: Maybe Text
$sel:image:Container' :: Container -> Maybe Text
image} -> Maybe Text
image) (\s :: Container
s@Container' {} Maybe Text
a -> Container
s {$sel:image:Container' :: Maybe Text
image = Maybe Text
a} :: Container)

-- | Part of the image name before the last slash. For example, imagePrefix
-- for public.ecr.aws\/amazonlinux\/amazonlinux:latest would be
-- public.ecr.aws\/amazonlinux. If the image name is relative and does not
-- have a slash, this field is empty.
container_imagePrefix :: Lens.Lens' Container (Prelude.Maybe Prelude.Text)
container_imagePrefix :: Lens' Container (Maybe Text)
container_imagePrefix = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe Text
imagePrefix :: Maybe Text
$sel:imagePrefix:Container' :: Container -> Maybe Text
imagePrefix} -> Maybe Text
imagePrefix) (\s :: Container
s@Container' {} Maybe Text
a -> Container
s {$sel:imagePrefix:Container' :: Maybe Text
imagePrefix = Maybe Text
a} :: Container)

-- | Container name.
container_name :: Lens.Lens' Container (Prelude.Maybe Prelude.Text)
container_name :: Lens' Container (Maybe Text)
container_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe Text
name :: Maybe Text
$sel:name:Container' :: Container -> Maybe Text
name} -> Maybe Text
name) (\s :: Container
s@Container' {} Maybe Text
a -> Container
s {$sel:name:Container' :: Maybe Text
name = Maybe Text
a} :: Container)

-- | Container security context.
container_securityContext :: Lens.Lens' Container (Prelude.Maybe SecurityContext)
container_securityContext :: Lens' Container (Maybe SecurityContext)
container_securityContext = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe SecurityContext
securityContext :: Maybe SecurityContext
$sel:securityContext:Container' :: Container -> Maybe SecurityContext
securityContext} -> Maybe SecurityContext
securityContext) (\s :: Container
s@Container' {} Maybe SecurityContext
a -> Container
s {$sel:securityContext:Container' :: Maybe SecurityContext
securityContext = Maybe SecurityContext
a} :: Container)

-- | Container volume mounts.
container_volumeMounts :: Lens.Lens' Container (Prelude.Maybe [VolumeMount])
container_volumeMounts :: Lens' Container (Maybe [VolumeMount])
container_volumeMounts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe [VolumeMount]
volumeMounts :: Maybe [VolumeMount]
$sel:volumeMounts:Container' :: Container -> Maybe [VolumeMount]
volumeMounts} -> Maybe [VolumeMount]
volumeMounts) (\s :: Container
s@Container' {} Maybe [VolumeMount]
a -> Container
s {$sel:volumeMounts:Container' :: Maybe [VolumeMount]
volumeMounts = Maybe [VolumeMount]
a} :: Container) 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 Container where
  parseJSON :: Value -> Parser Container
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Container"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe SecurityContext
-> Maybe [VolumeMount]
-> Container
Container'
            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
"containerRuntime")
            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
"id")
            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
"image")
            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
"imagePrefix")
            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
"name")
            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
"securityContext")
            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
"volumeMounts" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable Container where
  hashWithSalt :: Int -> Container -> Int
hashWithSalt Int
_salt Container' {Maybe [VolumeMount]
Maybe Text
Maybe SecurityContext
volumeMounts :: Maybe [VolumeMount]
securityContext :: Maybe SecurityContext
name :: Maybe Text
imagePrefix :: Maybe Text
image :: Maybe Text
id :: Maybe Text
containerRuntime :: Maybe Text
$sel:volumeMounts:Container' :: Container -> Maybe [VolumeMount]
$sel:securityContext:Container' :: Container -> Maybe SecurityContext
$sel:name:Container' :: Container -> Maybe Text
$sel:imagePrefix:Container' :: Container -> Maybe Text
$sel:image:Container' :: Container -> Maybe Text
$sel:id:Container' :: Container -> Maybe Text
$sel:containerRuntime:Container' :: Container -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
containerRuntime
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
image
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
imagePrefix
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SecurityContext
securityContext
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [VolumeMount]
volumeMounts

instance Prelude.NFData Container where
  rnf :: Container -> ()
rnf Container' {Maybe [VolumeMount]
Maybe Text
Maybe SecurityContext
volumeMounts :: Maybe [VolumeMount]
securityContext :: Maybe SecurityContext
name :: Maybe Text
imagePrefix :: Maybe Text
image :: Maybe Text
id :: Maybe Text
containerRuntime :: Maybe Text
$sel:volumeMounts:Container' :: Container -> Maybe [VolumeMount]
$sel:securityContext:Container' :: Container -> Maybe SecurityContext
$sel:name:Container' :: Container -> Maybe Text
$sel:imagePrefix:Container' :: Container -> Maybe Text
$sel:image:Container' :: Container -> Maybe Text
$sel:id:Container' :: Container -> Maybe Text
$sel:containerRuntime:Container' :: Container -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
containerRuntime
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
image
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
imagePrefix
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SecurityContext
securityContext
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [VolumeMount]
volumeMounts