{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.UpdateModelPackage
-- 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)
--
-- Updates a versioned model.
module Amazonka.SageMaker.UpdateModelPackage
  ( -- * Creating a Request
    UpdateModelPackage (..),
    newUpdateModelPackage,

    -- * Request Lenses
    updateModelPackage_approvalDescription,
    updateModelPackage_modelPackageArn,
    updateModelPackage_modelApprovalStatus,

    -- * Destructuring the Response
    UpdateModelPackageResponse (..),
    newUpdateModelPackageResponse,

    -- * Response Lenses
    updateModelPackageResponse_httpStatus,
    updateModelPackageResponse_modelPackageArn,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SageMaker.Types

-- | /See:/ 'newUpdateModelPackage' smart constructor.
data UpdateModelPackage = UpdateModelPackage'
  { -- | A description for the approval status of the model.
    UpdateModelPackage -> Maybe Text
approvalDescription :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the model.
    UpdateModelPackage -> Text
modelPackageArn :: Prelude.Text,
    -- | The approval status of the model.
    UpdateModelPackage -> ModelApprovalStatus
modelApprovalStatus :: ModelApprovalStatus
  }
  deriving (UpdateModelPackage -> UpdateModelPackage -> Bool
(UpdateModelPackage -> UpdateModelPackage -> Bool)
-> (UpdateModelPackage -> UpdateModelPackage -> Bool)
-> Eq UpdateModelPackage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateModelPackage -> UpdateModelPackage -> Bool
$c/= :: UpdateModelPackage -> UpdateModelPackage -> Bool
== :: UpdateModelPackage -> UpdateModelPackage -> Bool
$c== :: UpdateModelPackage -> UpdateModelPackage -> Bool
Prelude.Eq, ReadPrec [UpdateModelPackage]
ReadPrec UpdateModelPackage
Int -> ReadS UpdateModelPackage
ReadS [UpdateModelPackage]
(Int -> ReadS UpdateModelPackage)
-> ReadS [UpdateModelPackage]
-> ReadPrec UpdateModelPackage
-> ReadPrec [UpdateModelPackage]
-> Read UpdateModelPackage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateModelPackage]
$creadListPrec :: ReadPrec [UpdateModelPackage]
readPrec :: ReadPrec UpdateModelPackage
$creadPrec :: ReadPrec UpdateModelPackage
readList :: ReadS [UpdateModelPackage]
$creadList :: ReadS [UpdateModelPackage]
readsPrec :: Int -> ReadS UpdateModelPackage
$creadsPrec :: Int -> ReadS UpdateModelPackage
Prelude.Read, Int -> UpdateModelPackage -> ShowS
[UpdateModelPackage] -> ShowS
UpdateModelPackage -> String
(Int -> UpdateModelPackage -> ShowS)
-> (UpdateModelPackage -> String)
-> ([UpdateModelPackage] -> ShowS)
-> Show UpdateModelPackage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateModelPackage] -> ShowS
$cshowList :: [UpdateModelPackage] -> ShowS
show :: UpdateModelPackage -> String
$cshow :: UpdateModelPackage -> String
showsPrec :: Int -> UpdateModelPackage -> ShowS
$cshowsPrec :: Int -> UpdateModelPackage -> ShowS
Prelude.Show, (forall x. UpdateModelPackage -> Rep UpdateModelPackage x)
-> (forall x. Rep UpdateModelPackage x -> UpdateModelPackage)
-> Generic UpdateModelPackage
forall x. Rep UpdateModelPackage x -> UpdateModelPackage
forall x. UpdateModelPackage -> Rep UpdateModelPackage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateModelPackage x -> UpdateModelPackage
$cfrom :: forall x. UpdateModelPackage -> Rep UpdateModelPackage x
Prelude.Generic)

-- |
-- Create a value of 'UpdateModelPackage' 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:
--
-- 'approvalDescription', 'updateModelPackage_approvalDescription' - A description for the approval status of the model.
--
-- 'modelPackageArn', 'updateModelPackage_modelPackageArn' - The Amazon Resource Name (ARN) of the model.
--
-- 'modelApprovalStatus', 'updateModelPackage_modelApprovalStatus' - The approval status of the model.
newUpdateModelPackage ::
  -- | 'modelPackageArn'
  Prelude.Text ->
  -- | 'modelApprovalStatus'
  ModelApprovalStatus ->
  UpdateModelPackage
newUpdateModelPackage :: Text -> ModelApprovalStatus -> UpdateModelPackage
newUpdateModelPackage
  Text
pModelPackageArn_
  ModelApprovalStatus
pModelApprovalStatus_ =
    UpdateModelPackage' :: Maybe Text -> Text -> ModelApprovalStatus -> UpdateModelPackage
UpdateModelPackage'
      { $sel:approvalDescription:UpdateModelPackage' :: Maybe Text
approvalDescription =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:modelPackageArn:UpdateModelPackage' :: Text
modelPackageArn = Text
pModelPackageArn_,
        $sel:modelApprovalStatus:UpdateModelPackage' :: ModelApprovalStatus
modelApprovalStatus = ModelApprovalStatus
pModelApprovalStatus_
      }

-- | A description for the approval status of the model.
updateModelPackage_approvalDescription :: Lens.Lens' UpdateModelPackage (Prelude.Maybe Prelude.Text)
updateModelPackage_approvalDescription :: (Maybe Text -> f (Maybe Text))
-> UpdateModelPackage -> f UpdateModelPackage
updateModelPackage_approvalDescription = (UpdateModelPackage -> Maybe Text)
-> (UpdateModelPackage -> Maybe Text -> UpdateModelPackage)
-> Lens
     UpdateModelPackage UpdateModelPackage (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModelPackage' {Maybe Text
approvalDescription :: Maybe Text
$sel:approvalDescription:UpdateModelPackage' :: UpdateModelPackage -> Maybe Text
approvalDescription} -> Maybe Text
approvalDescription) (\s :: UpdateModelPackage
s@UpdateModelPackage' {} Maybe Text
a -> UpdateModelPackage
s {$sel:approvalDescription:UpdateModelPackage' :: Maybe Text
approvalDescription = Maybe Text
a} :: UpdateModelPackage)

-- | The Amazon Resource Name (ARN) of the model.
updateModelPackage_modelPackageArn :: Lens.Lens' UpdateModelPackage Prelude.Text
updateModelPackage_modelPackageArn :: (Text -> f Text) -> UpdateModelPackage -> f UpdateModelPackage
updateModelPackage_modelPackageArn = (UpdateModelPackage -> Text)
-> (UpdateModelPackage -> Text -> UpdateModelPackage)
-> Lens UpdateModelPackage UpdateModelPackage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModelPackage' {Text
modelPackageArn :: Text
$sel:modelPackageArn:UpdateModelPackage' :: UpdateModelPackage -> Text
modelPackageArn} -> Text
modelPackageArn) (\s :: UpdateModelPackage
s@UpdateModelPackage' {} Text
a -> UpdateModelPackage
s {$sel:modelPackageArn:UpdateModelPackage' :: Text
modelPackageArn = Text
a} :: UpdateModelPackage)

-- | The approval status of the model.
updateModelPackage_modelApprovalStatus :: Lens.Lens' UpdateModelPackage ModelApprovalStatus
updateModelPackage_modelApprovalStatus :: (ModelApprovalStatus -> f ModelApprovalStatus)
-> UpdateModelPackage -> f UpdateModelPackage
updateModelPackage_modelApprovalStatus = (UpdateModelPackage -> ModelApprovalStatus)
-> (UpdateModelPackage
    -> ModelApprovalStatus -> UpdateModelPackage)
-> Lens
     UpdateModelPackage
     UpdateModelPackage
     ModelApprovalStatus
     ModelApprovalStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModelPackage' {ModelApprovalStatus
modelApprovalStatus :: ModelApprovalStatus
$sel:modelApprovalStatus:UpdateModelPackage' :: UpdateModelPackage -> ModelApprovalStatus
modelApprovalStatus} -> ModelApprovalStatus
modelApprovalStatus) (\s :: UpdateModelPackage
s@UpdateModelPackage' {} ModelApprovalStatus
a -> UpdateModelPackage
s {$sel:modelApprovalStatus:UpdateModelPackage' :: ModelApprovalStatus
modelApprovalStatus = ModelApprovalStatus
a} :: UpdateModelPackage)

instance Core.AWSRequest UpdateModelPackage where
  type
    AWSResponse UpdateModelPackage =
      UpdateModelPackageResponse
  request :: UpdateModelPackage -> Request UpdateModelPackage
request = Service -> UpdateModelPackage -> Request UpdateModelPackage
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateModelPackage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateModelPackage)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateModelPackage))
-> Logger
-> Service
-> Proxy UpdateModelPackage
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateModelPackage)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> Text -> UpdateModelPackageResponse
UpdateModelPackageResponse'
            (Int -> Text -> UpdateModelPackageResponse)
-> Either String Int
-> Either String (Text -> UpdateModelPackageResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            Either String (Text -> UpdateModelPackageResponse)
-> Either String Text -> Either String UpdateModelPackageResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String Text
forall a. FromJSON a => Object -> Text -> Either String a
Core..:> Text
"ModelPackageArn")
      )

instance Prelude.Hashable UpdateModelPackage

instance Prelude.NFData UpdateModelPackage

instance Core.ToHeaders UpdateModelPackage where
  toHeaders :: UpdateModelPackage -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateModelPackage -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"SageMaker.UpdateModelPackage" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON UpdateModelPackage where
  toJSON :: UpdateModelPackage -> Value
toJSON UpdateModelPackage' {Maybe Text
Text
ModelApprovalStatus
modelApprovalStatus :: ModelApprovalStatus
modelPackageArn :: Text
approvalDescription :: Maybe Text
$sel:modelApprovalStatus:UpdateModelPackage' :: UpdateModelPackage -> ModelApprovalStatus
$sel:modelPackageArn:UpdateModelPackage' :: UpdateModelPackage -> Text
$sel:approvalDescription:UpdateModelPackage' :: UpdateModelPackage -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ApprovalDescription" 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
approvalDescription,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ModelPackageArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
modelPackageArn),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ModelApprovalStatus" Text -> ModelApprovalStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ModelApprovalStatus
modelApprovalStatus)
          ]
      )

instance Core.ToPath UpdateModelPackage where
  toPath :: UpdateModelPackage -> ByteString
toPath = ByteString -> UpdateModelPackage -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery UpdateModelPackage where
  toQuery :: UpdateModelPackage -> QueryString
toQuery = QueryString -> UpdateModelPackage -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateModelPackageResponse' smart constructor.
data UpdateModelPackageResponse = UpdateModelPackageResponse'
  { -- | The response's http status code.
    UpdateModelPackageResponse -> Int
httpStatus :: Prelude.Int,
    -- | The Amazon Resource Name (ARN) of the model.
    UpdateModelPackageResponse -> Text
modelPackageArn :: Prelude.Text
  }
  deriving (UpdateModelPackageResponse -> UpdateModelPackageResponse -> Bool
(UpdateModelPackageResponse -> UpdateModelPackageResponse -> Bool)
-> (UpdateModelPackageResponse
    -> UpdateModelPackageResponse -> Bool)
-> Eq UpdateModelPackageResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateModelPackageResponse -> UpdateModelPackageResponse -> Bool
$c/= :: UpdateModelPackageResponse -> UpdateModelPackageResponse -> Bool
== :: UpdateModelPackageResponse -> UpdateModelPackageResponse -> Bool
$c== :: UpdateModelPackageResponse -> UpdateModelPackageResponse -> Bool
Prelude.Eq, ReadPrec [UpdateModelPackageResponse]
ReadPrec UpdateModelPackageResponse
Int -> ReadS UpdateModelPackageResponse
ReadS [UpdateModelPackageResponse]
(Int -> ReadS UpdateModelPackageResponse)
-> ReadS [UpdateModelPackageResponse]
-> ReadPrec UpdateModelPackageResponse
-> ReadPrec [UpdateModelPackageResponse]
-> Read UpdateModelPackageResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateModelPackageResponse]
$creadListPrec :: ReadPrec [UpdateModelPackageResponse]
readPrec :: ReadPrec UpdateModelPackageResponse
$creadPrec :: ReadPrec UpdateModelPackageResponse
readList :: ReadS [UpdateModelPackageResponse]
$creadList :: ReadS [UpdateModelPackageResponse]
readsPrec :: Int -> ReadS UpdateModelPackageResponse
$creadsPrec :: Int -> ReadS UpdateModelPackageResponse
Prelude.Read, Int -> UpdateModelPackageResponse -> ShowS
[UpdateModelPackageResponse] -> ShowS
UpdateModelPackageResponse -> String
(Int -> UpdateModelPackageResponse -> ShowS)
-> (UpdateModelPackageResponse -> String)
-> ([UpdateModelPackageResponse] -> ShowS)
-> Show UpdateModelPackageResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateModelPackageResponse] -> ShowS
$cshowList :: [UpdateModelPackageResponse] -> ShowS
show :: UpdateModelPackageResponse -> String
$cshow :: UpdateModelPackageResponse -> String
showsPrec :: Int -> UpdateModelPackageResponse -> ShowS
$cshowsPrec :: Int -> UpdateModelPackageResponse -> ShowS
Prelude.Show, (forall x.
 UpdateModelPackageResponse -> Rep UpdateModelPackageResponse x)
-> (forall x.
    Rep UpdateModelPackageResponse x -> UpdateModelPackageResponse)
-> Generic UpdateModelPackageResponse
forall x.
Rep UpdateModelPackageResponse x -> UpdateModelPackageResponse
forall x.
UpdateModelPackageResponse -> Rep UpdateModelPackageResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateModelPackageResponse x -> UpdateModelPackageResponse
$cfrom :: forall x.
UpdateModelPackageResponse -> Rep UpdateModelPackageResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateModelPackageResponse' 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:
--
-- 'httpStatus', 'updateModelPackageResponse_httpStatus' - The response's http status code.
--
-- 'modelPackageArn', 'updateModelPackageResponse_modelPackageArn' - The Amazon Resource Name (ARN) of the model.
newUpdateModelPackageResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'modelPackageArn'
  Prelude.Text ->
  UpdateModelPackageResponse
newUpdateModelPackageResponse :: Int -> Text -> UpdateModelPackageResponse
newUpdateModelPackageResponse
  Int
pHttpStatus_
  Text
pModelPackageArn_ =
    UpdateModelPackageResponse' :: Int -> Text -> UpdateModelPackageResponse
UpdateModelPackageResponse'
      { $sel:httpStatus:UpdateModelPackageResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:modelPackageArn:UpdateModelPackageResponse' :: Text
modelPackageArn = Text
pModelPackageArn_
      }

-- | The response's http status code.
updateModelPackageResponse_httpStatus :: Lens.Lens' UpdateModelPackageResponse Prelude.Int
updateModelPackageResponse_httpStatus :: (Int -> f Int)
-> UpdateModelPackageResponse -> f UpdateModelPackageResponse
updateModelPackageResponse_httpStatus = (UpdateModelPackageResponse -> Int)
-> (UpdateModelPackageResponse
    -> Int -> UpdateModelPackageResponse)
-> Lens
     UpdateModelPackageResponse UpdateModelPackageResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModelPackageResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateModelPackageResponse' :: UpdateModelPackageResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateModelPackageResponse
s@UpdateModelPackageResponse' {} Int
a -> UpdateModelPackageResponse
s {$sel:httpStatus:UpdateModelPackageResponse' :: Int
httpStatus = Int
a} :: UpdateModelPackageResponse)

-- | The Amazon Resource Name (ARN) of the model.
updateModelPackageResponse_modelPackageArn :: Lens.Lens' UpdateModelPackageResponse Prelude.Text
updateModelPackageResponse_modelPackageArn :: (Text -> f Text)
-> UpdateModelPackageResponse -> f UpdateModelPackageResponse
updateModelPackageResponse_modelPackageArn = (UpdateModelPackageResponse -> Text)
-> (UpdateModelPackageResponse
    -> Text -> UpdateModelPackageResponse)
-> Lens
     UpdateModelPackageResponse UpdateModelPackageResponse Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateModelPackageResponse' {Text
modelPackageArn :: Text
$sel:modelPackageArn:UpdateModelPackageResponse' :: UpdateModelPackageResponse -> Text
modelPackageArn} -> Text
modelPackageArn) (\s :: UpdateModelPackageResponse
s@UpdateModelPackageResponse' {} Text
a -> UpdateModelPackageResponse
s {$sel:modelPackageArn:UpdateModelPackageResponse' :: Text
modelPackageArn = Text
a} :: UpdateModelPackageResponse)

instance Prelude.NFData UpdateModelPackageResponse