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

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

-- | Specifies how to generate the endpoint name for an automatic one-click
-- Autopilot model deployment.
--
-- /See:/ 'newModelDeployConfig' smart constructor.
data ModelDeployConfig = ModelDeployConfig'
  { -- | Specifies the endpoint name to use for a one-click Autopilot model
    -- deployment if the endpoint name is not generated automatically.
    --
    -- Specify the @EndpointName@ if and only if you set
    -- @AutoGenerateEndpointName@ to @False@; otherwise a 400 error is thrown.
    ModelDeployConfig -> Maybe Text
endpointName :: Prelude.Maybe Prelude.Text,
    -- | Set to @True@ to automatically generate an endpoint name for a one-click
    -- Autopilot model deployment; set to @False@ otherwise. The default value
    -- is @False@.
    --
    -- If you set @AutoGenerateEndpointName@ to @True@, do not specify the
    -- @EndpointName@; otherwise a 400 error is thrown.
    ModelDeployConfig -> Maybe Bool
autoGenerateEndpointName :: Prelude.Maybe Prelude.Bool
  }
  deriving (ModelDeployConfig -> ModelDeployConfig -> Bool
(ModelDeployConfig -> ModelDeployConfig -> Bool)
-> (ModelDeployConfig -> ModelDeployConfig -> Bool)
-> Eq ModelDeployConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModelDeployConfig -> ModelDeployConfig -> Bool
$c/= :: ModelDeployConfig -> ModelDeployConfig -> Bool
== :: ModelDeployConfig -> ModelDeployConfig -> Bool
$c== :: ModelDeployConfig -> ModelDeployConfig -> Bool
Prelude.Eq, ReadPrec [ModelDeployConfig]
ReadPrec ModelDeployConfig
Int -> ReadS ModelDeployConfig
ReadS [ModelDeployConfig]
(Int -> ReadS ModelDeployConfig)
-> ReadS [ModelDeployConfig]
-> ReadPrec ModelDeployConfig
-> ReadPrec [ModelDeployConfig]
-> Read ModelDeployConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModelDeployConfig]
$creadListPrec :: ReadPrec [ModelDeployConfig]
readPrec :: ReadPrec ModelDeployConfig
$creadPrec :: ReadPrec ModelDeployConfig
readList :: ReadS [ModelDeployConfig]
$creadList :: ReadS [ModelDeployConfig]
readsPrec :: Int -> ReadS ModelDeployConfig
$creadsPrec :: Int -> ReadS ModelDeployConfig
Prelude.Read, Int -> ModelDeployConfig -> ShowS
[ModelDeployConfig] -> ShowS
ModelDeployConfig -> String
(Int -> ModelDeployConfig -> ShowS)
-> (ModelDeployConfig -> String)
-> ([ModelDeployConfig] -> ShowS)
-> Show ModelDeployConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModelDeployConfig] -> ShowS
$cshowList :: [ModelDeployConfig] -> ShowS
show :: ModelDeployConfig -> String
$cshow :: ModelDeployConfig -> String
showsPrec :: Int -> ModelDeployConfig -> ShowS
$cshowsPrec :: Int -> ModelDeployConfig -> ShowS
Prelude.Show, (forall x. ModelDeployConfig -> Rep ModelDeployConfig x)
-> (forall x. Rep ModelDeployConfig x -> ModelDeployConfig)
-> Generic ModelDeployConfig
forall x. Rep ModelDeployConfig x -> ModelDeployConfig
forall x. ModelDeployConfig -> Rep ModelDeployConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModelDeployConfig x -> ModelDeployConfig
$cfrom :: forall x. ModelDeployConfig -> Rep ModelDeployConfig x
Prelude.Generic)

-- |
-- Create a value of 'ModelDeployConfig' 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:
--
-- 'endpointName', 'modelDeployConfig_endpointName' - Specifies the endpoint name to use for a one-click Autopilot model
-- deployment if the endpoint name is not generated automatically.
--
-- Specify the @EndpointName@ if and only if you set
-- @AutoGenerateEndpointName@ to @False@; otherwise a 400 error is thrown.
--
-- 'autoGenerateEndpointName', 'modelDeployConfig_autoGenerateEndpointName' - Set to @True@ to automatically generate an endpoint name for a one-click
-- Autopilot model deployment; set to @False@ otherwise. The default value
-- is @False@.
--
-- If you set @AutoGenerateEndpointName@ to @True@, do not specify the
-- @EndpointName@; otherwise a 400 error is thrown.
newModelDeployConfig ::
  ModelDeployConfig
newModelDeployConfig :: ModelDeployConfig
newModelDeployConfig =
  ModelDeployConfig' :: Maybe Text -> Maybe Bool -> ModelDeployConfig
ModelDeployConfig'
    { $sel:endpointName:ModelDeployConfig' :: Maybe Text
endpointName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:autoGenerateEndpointName:ModelDeployConfig' :: Maybe Bool
autoGenerateEndpointName = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies the endpoint name to use for a one-click Autopilot model
-- deployment if the endpoint name is not generated automatically.
--
-- Specify the @EndpointName@ if and only if you set
-- @AutoGenerateEndpointName@ to @False@; otherwise a 400 error is thrown.
modelDeployConfig_endpointName :: Lens.Lens' ModelDeployConfig (Prelude.Maybe Prelude.Text)
modelDeployConfig_endpointName :: (Maybe Text -> f (Maybe Text))
-> ModelDeployConfig -> f ModelDeployConfig
modelDeployConfig_endpointName = (ModelDeployConfig -> Maybe Text)
-> (ModelDeployConfig -> Maybe Text -> ModelDeployConfig)
-> Lens
     ModelDeployConfig ModelDeployConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelDeployConfig' {Maybe Text
endpointName :: Maybe Text
$sel:endpointName:ModelDeployConfig' :: ModelDeployConfig -> Maybe Text
endpointName} -> Maybe Text
endpointName) (\s :: ModelDeployConfig
s@ModelDeployConfig' {} Maybe Text
a -> ModelDeployConfig
s {$sel:endpointName:ModelDeployConfig' :: Maybe Text
endpointName = Maybe Text
a} :: ModelDeployConfig)

-- | Set to @True@ to automatically generate an endpoint name for a one-click
-- Autopilot model deployment; set to @False@ otherwise. The default value
-- is @False@.
--
-- If you set @AutoGenerateEndpointName@ to @True@, do not specify the
-- @EndpointName@; otherwise a 400 error is thrown.
modelDeployConfig_autoGenerateEndpointName :: Lens.Lens' ModelDeployConfig (Prelude.Maybe Prelude.Bool)
modelDeployConfig_autoGenerateEndpointName :: (Maybe Bool -> f (Maybe Bool))
-> ModelDeployConfig -> f ModelDeployConfig
modelDeployConfig_autoGenerateEndpointName = (ModelDeployConfig -> Maybe Bool)
-> (ModelDeployConfig -> Maybe Bool -> ModelDeployConfig)
-> Lens
     ModelDeployConfig ModelDeployConfig (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModelDeployConfig' {Maybe Bool
autoGenerateEndpointName :: Maybe Bool
$sel:autoGenerateEndpointName:ModelDeployConfig' :: ModelDeployConfig -> Maybe Bool
autoGenerateEndpointName} -> Maybe Bool
autoGenerateEndpointName) (\s :: ModelDeployConfig
s@ModelDeployConfig' {} Maybe Bool
a -> ModelDeployConfig
s {$sel:autoGenerateEndpointName:ModelDeployConfig' :: Maybe Bool
autoGenerateEndpointName = Maybe Bool
a} :: ModelDeployConfig)

instance Core.FromJSON ModelDeployConfig where
  parseJSON :: Value -> Parser ModelDeployConfig
parseJSON =
    String
-> (Object -> Parser ModelDeployConfig)
-> Value
-> Parser ModelDeployConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ModelDeployConfig"
      ( \Object
x ->
          Maybe Text -> Maybe Bool -> ModelDeployConfig
ModelDeployConfig'
            (Maybe Text -> Maybe Bool -> ModelDeployConfig)
-> Parser (Maybe Text) -> Parser (Maybe Bool -> ModelDeployConfig)
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
"EndpointName")
            Parser (Maybe Bool -> ModelDeployConfig)
-> Parser (Maybe Bool) -> Parser ModelDeployConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AutoGenerateEndpointName")
      )

instance Prelude.Hashable ModelDeployConfig

instance Prelude.NFData ModelDeployConfig

instance Core.ToJSON ModelDeployConfig where
  toJSON :: ModelDeployConfig -> Value
toJSON ModelDeployConfig' {Maybe Bool
Maybe Text
autoGenerateEndpointName :: Maybe Bool
endpointName :: Maybe Text
$sel:autoGenerateEndpointName:ModelDeployConfig' :: ModelDeployConfig -> Maybe Bool
$sel:endpointName:ModelDeployConfig' :: ModelDeployConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"EndpointName" 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
endpointName,
            (Text
"AutoGenerateEndpointName" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
autoGenerateEndpointName
          ]
      )