{-# 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.RepositoryAuthConfig
-- 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.RepositoryAuthConfig where

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

-- | 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 of the @ImageConfig@ object that you passed
-- to a call to @CreateModel@ and the private Docker registry where the
-- model image is hosted requires authentication.
--
-- /See:/ 'newRepositoryAuthConfig' smart constructor.
data RepositoryAuthConfig = RepositoryAuthConfig'
  { -- | The Amazon Resource Name (ARN) of an Amazon Web Services Lambda function
    -- that provides credentials to authenticate to the private Docker registry
    -- where your model image is hosted. For information about how to create an
    -- Amazon Web Services Lambda function, see
    -- <https://docs.aws.amazon.com/lambda/latest/dg/getting-started-create-function.html Create a Lambda function with the console>
    -- in the /Amazon Web Services Lambda Developer Guide/.
    RepositoryAuthConfig -> Text
repositoryCredentialsProviderArn :: Prelude.Text
  }
  deriving (RepositoryAuthConfig -> RepositoryAuthConfig -> Bool
(RepositoryAuthConfig -> RepositoryAuthConfig -> Bool)
-> (RepositoryAuthConfig -> RepositoryAuthConfig -> Bool)
-> Eq RepositoryAuthConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RepositoryAuthConfig -> RepositoryAuthConfig -> Bool
$c/= :: RepositoryAuthConfig -> RepositoryAuthConfig -> Bool
== :: RepositoryAuthConfig -> RepositoryAuthConfig -> Bool
$c== :: RepositoryAuthConfig -> RepositoryAuthConfig -> Bool
Prelude.Eq, ReadPrec [RepositoryAuthConfig]
ReadPrec RepositoryAuthConfig
Int -> ReadS RepositoryAuthConfig
ReadS [RepositoryAuthConfig]
(Int -> ReadS RepositoryAuthConfig)
-> ReadS [RepositoryAuthConfig]
-> ReadPrec RepositoryAuthConfig
-> ReadPrec [RepositoryAuthConfig]
-> Read RepositoryAuthConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RepositoryAuthConfig]
$creadListPrec :: ReadPrec [RepositoryAuthConfig]
readPrec :: ReadPrec RepositoryAuthConfig
$creadPrec :: ReadPrec RepositoryAuthConfig
readList :: ReadS [RepositoryAuthConfig]
$creadList :: ReadS [RepositoryAuthConfig]
readsPrec :: Int -> ReadS RepositoryAuthConfig
$creadsPrec :: Int -> ReadS RepositoryAuthConfig
Prelude.Read, Int -> RepositoryAuthConfig -> ShowS
[RepositoryAuthConfig] -> ShowS
RepositoryAuthConfig -> String
(Int -> RepositoryAuthConfig -> ShowS)
-> (RepositoryAuthConfig -> String)
-> ([RepositoryAuthConfig] -> ShowS)
-> Show RepositoryAuthConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RepositoryAuthConfig] -> ShowS
$cshowList :: [RepositoryAuthConfig] -> ShowS
show :: RepositoryAuthConfig -> String
$cshow :: RepositoryAuthConfig -> String
showsPrec :: Int -> RepositoryAuthConfig -> ShowS
$cshowsPrec :: Int -> RepositoryAuthConfig -> ShowS
Prelude.Show, (forall x. RepositoryAuthConfig -> Rep RepositoryAuthConfig x)
-> (forall x. Rep RepositoryAuthConfig x -> RepositoryAuthConfig)
-> Generic RepositoryAuthConfig
forall x. Rep RepositoryAuthConfig x -> RepositoryAuthConfig
forall x. RepositoryAuthConfig -> Rep RepositoryAuthConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RepositoryAuthConfig x -> RepositoryAuthConfig
$cfrom :: forall x. RepositoryAuthConfig -> Rep RepositoryAuthConfig x
Prelude.Generic)

-- |
-- Create a value of 'RepositoryAuthConfig' 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:
--
-- 'repositoryCredentialsProviderArn', 'repositoryAuthConfig_repositoryCredentialsProviderArn' - The Amazon Resource Name (ARN) of an Amazon Web Services Lambda function
-- that provides credentials to authenticate to the private Docker registry
-- where your model image is hosted. For information about how to create an
-- Amazon Web Services Lambda function, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/getting-started-create-function.html Create a Lambda function with the console>
-- in the /Amazon Web Services Lambda Developer Guide/.
newRepositoryAuthConfig ::
  -- | 'repositoryCredentialsProviderArn'
  Prelude.Text ->
  RepositoryAuthConfig
newRepositoryAuthConfig :: Text -> RepositoryAuthConfig
newRepositoryAuthConfig
  Text
pRepositoryCredentialsProviderArn_ =
    RepositoryAuthConfig' :: Text -> RepositoryAuthConfig
RepositoryAuthConfig'
      { $sel:repositoryCredentialsProviderArn:RepositoryAuthConfig' :: Text
repositoryCredentialsProviderArn =
          Text
pRepositoryCredentialsProviderArn_
      }

-- | The Amazon Resource Name (ARN) of an Amazon Web Services Lambda function
-- that provides credentials to authenticate to the private Docker registry
-- where your model image is hosted. For information about how to create an
-- Amazon Web Services Lambda function, see
-- <https://docs.aws.amazon.com/lambda/latest/dg/getting-started-create-function.html Create a Lambda function with the console>
-- in the /Amazon Web Services Lambda Developer Guide/.
repositoryAuthConfig_repositoryCredentialsProviderArn :: Lens.Lens' RepositoryAuthConfig Prelude.Text
repositoryAuthConfig_repositoryCredentialsProviderArn :: (Text -> f Text) -> RepositoryAuthConfig -> f RepositoryAuthConfig
repositoryAuthConfig_repositoryCredentialsProviderArn = (RepositoryAuthConfig -> Text)
-> (RepositoryAuthConfig -> Text -> RepositoryAuthConfig)
-> Lens RepositoryAuthConfig RepositoryAuthConfig Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RepositoryAuthConfig' {Text
repositoryCredentialsProviderArn :: Text
$sel:repositoryCredentialsProviderArn:RepositoryAuthConfig' :: RepositoryAuthConfig -> Text
repositoryCredentialsProviderArn} -> Text
repositoryCredentialsProviderArn) (\s :: RepositoryAuthConfig
s@RepositoryAuthConfig' {} Text
a -> RepositoryAuthConfig
s {$sel:repositoryCredentialsProviderArn:RepositoryAuthConfig' :: Text
repositoryCredentialsProviderArn = Text
a} :: RepositoryAuthConfig)

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

instance Prelude.Hashable RepositoryAuthConfig

instance Prelude.NFData RepositoryAuthConfig

instance Core.ToJSON RepositoryAuthConfig where
  toJSON :: RepositoryAuthConfig -> Value
toJSON RepositoryAuthConfig' {Text
repositoryCredentialsProviderArn :: Text
$sel:repositoryCredentialsProviderArn:RepositoryAuthConfig' :: RepositoryAuthConfig -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"RepositoryCredentialsProviderArn"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
repositoryCredentialsProviderArn
              )
          ]
      )