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

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

-- | A container encapsulates the runtime environment for an application.
--
-- /See:/ 'newContainer' smart constructor.
data Container = Container'
  { -- | A list of URIs for containers created in the context Region.
    Container -> Maybe [Text]
imageUris :: Prelude.Maybe [Prelude.Text],
    -- | Containers and container images are Region-specific. This is the Region
    -- context for the container.
    Container -> Maybe Text
region :: Prelude.Maybe Prelude.Text
  }
  deriving (Container -> Container -> Bool
(Container -> Container -> Bool)
-> (Container -> Container -> Bool) -> Eq Container
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]
(Int -> ReadS Container)
-> ReadS [Container]
-> ReadPrec Container
-> ReadPrec [Container]
-> Read 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
(Int -> Container -> ShowS)
-> (Container -> String)
-> ([Container] -> ShowS)
-> Show Container
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. Container -> Rep Container x)
-> (forall x. Rep Container x -> Container) -> Generic Container
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:
--
-- 'imageUris', 'container_imageUris' - A list of URIs for containers created in the context Region.
--
-- 'region', 'container_region' - Containers and container images are Region-specific. This is the Region
-- context for the container.
newContainer ::
  Container
newContainer :: Container
newContainer =
  Container' :: Maybe [Text] -> Maybe Text -> Container
Container'
    { $sel:imageUris:Container' :: Maybe [Text]
imageUris = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:region:Container' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A list of URIs for containers created in the context Region.
container_imageUris :: Lens.Lens' Container (Prelude.Maybe [Prelude.Text])
container_imageUris :: (Maybe [Text] -> f (Maybe [Text])) -> Container -> f Container
container_imageUris = (Container -> Maybe [Text])
-> (Container -> Maybe [Text] -> Container)
-> Lens Container Container (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe [Text]
imageUris :: Maybe [Text]
$sel:imageUris:Container' :: Container -> Maybe [Text]
imageUris} -> Maybe [Text]
imageUris) (\s :: Container
s@Container' {} Maybe [Text]
a -> Container
s {$sel:imageUris:Container' :: Maybe [Text]
imageUris = Maybe [Text]
a} :: Container) ((Maybe [Text] -> f (Maybe [Text])) -> Container -> f Container)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> Container
-> f Container
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Containers and container images are Region-specific. This is the Region
-- context for the container.
container_region :: Lens.Lens' Container (Prelude.Maybe Prelude.Text)
container_region :: (Maybe Text -> f (Maybe Text)) -> Container -> f Container
container_region = (Container -> Maybe Text)
-> (Container -> Maybe Text -> Container)
-> Lens Container Container (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Container' {Maybe Text
region :: Maybe Text
$sel:region:Container' :: Container -> Maybe Text
region} -> Maybe Text
region) (\s :: Container
s@Container' {} Maybe Text
a -> Container
s {$sel:region:Container' :: Maybe Text
region = Maybe Text
a} :: Container)

instance Core.FromJSON Container where
  parseJSON :: Value -> Parser Container
parseJSON =
    String -> (Object -> Parser Container) -> Value -> Parser Container
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Container"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> Container
Container'
            (Maybe [Text] -> Maybe Text -> Container)
-> Parser (Maybe [Text]) -> Parser (Maybe Text -> Container)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"imageUris" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> Container)
-> Parser (Maybe Text) -> Parser Container
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
"region")
      )

instance Prelude.Hashable Container

instance Prelude.NFData Container