{-# 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.SageMaker.Types.ImageConfig
-- 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.SageMaker.Types.ImageConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.RepositoryAccessMode
import Amazonka.SageMaker.Types.RepositoryAuthConfig

-- | Specifies whether the model container is in Amazon ECR or a private
-- Docker registry accessible from your Amazon Virtual Private Cloud (VPC).
--
-- /See:/ 'newImageConfig' smart constructor.
data ImageConfig = ImageConfig'
  { -- | (Optional) Specifies an authentication configuration for the private
    -- docker registry where your model image is hosted. Specify a value for
    -- this property only if you specified @Vpc@ as the value for the
    -- @RepositoryAccessMode@ field, and the private Docker registry where the
    -- model image is hosted requires authentication.
    ImageConfig -> Maybe RepositoryAuthConfig
repositoryAuthConfig :: Prelude.Maybe RepositoryAuthConfig,
    -- | Set this to one of the following values:
    --
    -- -   @Platform@ - The model image is hosted in Amazon ECR.
    --
    -- -   @Vpc@ - The model image is hosted in a private Docker registry in
    --     your VPC.
    ImageConfig -> RepositoryAccessMode
repositoryAccessMode :: RepositoryAccessMode
  }
  deriving (ImageConfig -> ImageConfig -> Bool
(ImageConfig -> ImageConfig -> Bool)
-> (ImageConfig -> ImageConfig -> Bool) -> Eq ImageConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageConfig -> ImageConfig -> Bool
$c/= :: ImageConfig -> ImageConfig -> Bool
== :: ImageConfig -> ImageConfig -> Bool
$c== :: ImageConfig -> ImageConfig -> Bool
Prelude.Eq, ReadPrec [ImageConfig]
ReadPrec ImageConfig
Int -> ReadS ImageConfig
ReadS [ImageConfig]
(Int -> ReadS ImageConfig)
-> ReadS [ImageConfig]
-> ReadPrec ImageConfig
-> ReadPrec [ImageConfig]
-> Read ImageConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageConfig]
$creadListPrec :: ReadPrec [ImageConfig]
readPrec :: ReadPrec ImageConfig
$creadPrec :: ReadPrec ImageConfig
readList :: ReadS [ImageConfig]
$creadList :: ReadS [ImageConfig]
readsPrec :: Int -> ReadS ImageConfig
$creadsPrec :: Int -> ReadS ImageConfig
Prelude.Read, Int -> ImageConfig -> ShowS
[ImageConfig] -> ShowS
ImageConfig -> String
(Int -> ImageConfig -> ShowS)
-> (ImageConfig -> String)
-> ([ImageConfig] -> ShowS)
-> Show ImageConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageConfig] -> ShowS
$cshowList :: [ImageConfig] -> ShowS
show :: ImageConfig -> String
$cshow :: ImageConfig -> String
showsPrec :: Int -> ImageConfig -> ShowS
$cshowsPrec :: Int -> ImageConfig -> ShowS
Prelude.Show, (forall x. ImageConfig -> Rep ImageConfig x)
-> (forall x. Rep ImageConfig x -> ImageConfig)
-> Generic ImageConfig
forall x. Rep ImageConfig x -> ImageConfig
forall x. ImageConfig -> Rep ImageConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageConfig x -> ImageConfig
$cfrom :: forall x. ImageConfig -> Rep ImageConfig x
Prelude.Generic)

-- |
-- Create a value of 'ImageConfig' 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:
--
-- 'repositoryAuthConfig', 'imageConfig_repositoryAuthConfig' - (Optional) Specifies an authentication configuration for the private
-- docker registry where your model image is hosted. Specify a value for
-- this property only if you specified @Vpc@ as the value for the
-- @RepositoryAccessMode@ field, and the private Docker registry where the
-- model image is hosted requires authentication.
--
-- 'repositoryAccessMode', 'imageConfig_repositoryAccessMode' - Set this to one of the following values:
--
-- -   @Platform@ - The model image is hosted in Amazon ECR.
--
-- -   @Vpc@ - The model image is hosted in a private Docker registry in
--     your VPC.
newImageConfig ::
  -- | 'repositoryAccessMode'
  RepositoryAccessMode ->
  ImageConfig
newImageConfig :: RepositoryAccessMode -> ImageConfig
newImageConfig RepositoryAccessMode
pRepositoryAccessMode_ =
  ImageConfig' :: Maybe RepositoryAuthConfig -> RepositoryAccessMode -> ImageConfig
ImageConfig'
    { $sel:repositoryAuthConfig:ImageConfig' :: Maybe RepositoryAuthConfig
repositoryAuthConfig =
        Maybe RepositoryAuthConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:repositoryAccessMode:ImageConfig' :: RepositoryAccessMode
repositoryAccessMode = RepositoryAccessMode
pRepositoryAccessMode_
    }

-- | (Optional) Specifies an authentication configuration for the private
-- docker registry where your model image is hosted. Specify a value for
-- this property only if you specified @Vpc@ as the value for the
-- @RepositoryAccessMode@ field, and the private Docker registry where the
-- model image is hosted requires authentication.
imageConfig_repositoryAuthConfig :: Lens.Lens' ImageConfig (Prelude.Maybe RepositoryAuthConfig)
imageConfig_repositoryAuthConfig :: (Maybe RepositoryAuthConfig -> f (Maybe RepositoryAuthConfig))
-> ImageConfig -> f ImageConfig
imageConfig_repositoryAuthConfig = (ImageConfig -> Maybe RepositoryAuthConfig)
-> (ImageConfig -> Maybe RepositoryAuthConfig -> ImageConfig)
-> Lens
     ImageConfig
     ImageConfig
     (Maybe RepositoryAuthConfig)
     (Maybe RepositoryAuthConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageConfig' {Maybe RepositoryAuthConfig
repositoryAuthConfig :: Maybe RepositoryAuthConfig
$sel:repositoryAuthConfig:ImageConfig' :: ImageConfig -> Maybe RepositoryAuthConfig
repositoryAuthConfig} -> Maybe RepositoryAuthConfig
repositoryAuthConfig) (\s :: ImageConfig
s@ImageConfig' {} Maybe RepositoryAuthConfig
a -> ImageConfig
s {$sel:repositoryAuthConfig:ImageConfig' :: Maybe RepositoryAuthConfig
repositoryAuthConfig = Maybe RepositoryAuthConfig
a} :: ImageConfig)

-- | Set this to one of the following values:
--
-- -   @Platform@ - The model image is hosted in Amazon ECR.
--
-- -   @Vpc@ - The model image is hosted in a private Docker registry in
--     your VPC.
imageConfig_repositoryAccessMode :: Lens.Lens' ImageConfig RepositoryAccessMode
imageConfig_repositoryAccessMode :: (RepositoryAccessMode -> f RepositoryAccessMode)
-> ImageConfig -> f ImageConfig
imageConfig_repositoryAccessMode = (ImageConfig -> RepositoryAccessMode)
-> (ImageConfig -> RepositoryAccessMode -> ImageConfig)
-> Lens
     ImageConfig ImageConfig RepositoryAccessMode RepositoryAccessMode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageConfig' {RepositoryAccessMode
repositoryAccessMode :: RepositoryAccessMode
$sel:repositoryAccessMode:ImageConfig' :: ImageConfig -> RepositoryAccessMode
repositoryAccessMode} -> RepositoryAccessMode
repositoryAccessMode) (\s :: ImageConfig
s@ImageConfig' {} RepositoryAccessMode
a -> ImageConfig
s {$sel:repositoryAccessMode:ImageConfig' :: RepositoryAccessMode
repositoryAccessMode = RepositoryAccessMode
a} :: ImageConfig)

instance Core.FromJSON ImageConfig where
  parseJSON :: Value -> Parser ImageConfig
parseJSON =
    String
-> (Object -> Parser ImageConfig) -> Value -> Parser ImageConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageConfig"
      ( \Object
x ->
          Maybe RepositoryAuthConfig -> RepositoryAccessMode -> ImageConfig
ImageConfig'
            (Maybe RepositoryAuthConfig -> RepositoryAccessMode -> ImageConfig)
-> Parser (Maybe RepositoryAuthConfig)
-> Parser (RepositoryAccessMode -> ImageConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe RepositoryAuthConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RepositoryAuthConfig")
            Parser (RepositoryAccessMode -> ImageConfig)
-> Parser RepositoryAccessMode -> Parser ImageConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RepositoryAccessMode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RepositoryAccessMode")
      )

instance Prelude.Hashable ImageConfig

instance Prelude.NFData ImageConfig

instance Core.ToJSON ImageConfig where
  toJSON :: ImageConfig -> Value
toJSON ImageConfig' {Maybe RepositoryAuthConfig
RepositoryAccessMode
repositoryAccessMode :: RepositoryAccessMode
repositoryAuthConfig :: Maybe RepositoryAuthConfig
$sel:repositoryAccessMode:ImageConfig' :: ImageConfig -> RepositoryAccessMode
$sel:repositoryAuthConfig:ImageConfig' :: ImageConfig -> Maybe RepositoryAuthConfig
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RepositoryAuthConfig" Text -> RepositoryAuthConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RepositoryAuthConfig -> Pair)
-> Maybe RepositoryAuthConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RepositoryAuthConfig
repositoryAuthConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"RepositoryAccessMode"
                  Text -> RepositoryAccessMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RepositoryAccessMode
repositoryAccessMode
              )
          ]
      )