{-# 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.Comprehend.UpdateEndpoint
-- 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 information about the specified endpoint.
module Amazonka.Comprehend.UpdateEndpoint
  ( -- * Creating a Request
    UpdateEndpoint (..),
    newUpdateEndpoint,

    -- * Request Lenses
    updateEndpoint_desiredModelArn,
    updateEndpoint_desiredInferenceUnits,
    updateEndpoint_desiredDataAccessRoleArn,
    updateEndpoint_endpointArn,

    -- * Destructuring the Response
    UpdateEndpointResponse (..),
    newUpdateEndpointResponse,

    -- * Response Lenses
    updateEndpointResponse_httpStatus,
  )
where

import Amazonka.Comprehend.Types
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

-- | /See:/ 'newUpdateEndpoint' smart constructor.
data UpdateEndpoint = UpdateEndpoint'
  { -- | The ARN of the new model to use when updating an existing endpoint.
    UpdateEndpoint -> Maybe Text
desiredModelArn :: Prelude.Maybe Prelude.Text,
    -- | The desired number of inference units to be used by the model using this
    -- endpoint. Each inference unit represents of a throughput of 100
    -- characters per second.
    UpdateEndpoint -> Maybe Natural
desiredInferenceUnits :: Prelude.Maybe Prelude.Natural,
    -- | Data access role ARN to use in case the new model is encrypted with a
    -- customer CMK.
    UpdateEndpoint -> Maybe Text
desiredDataAccessRoleArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Number (ARN) of the endpoint being updated.
    UpdateEndpoint -> Text
endpointArn :: Prelude.Text
  }
  deriving (UpdateEndpoint -> UpdateEndpoint -> Bool
(UpdateEndpoint -> UpdateEndpoint -> Bool)
-> (UpdateEndpoint -> UpdateEndpoint -> Bool) -> Eq UpdateEndpoint
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateEndpoint -> UpdateEndpoint -> Bool
$c/= :: UpdateEndpoint -> UpdateEndpoint -> Bool
== :: UpdateEndpoint -> UpdateEndpoint -> Bool
$c== :: UpdateEndpoint -> UpdateEndpoint -> Bool
Prelude.Eq, ReadPrec [UpdateEndpoint]
ReadPrec UpdateEndpoint
Int -> ReadS UpdateEndpoint
ReadS [UpdateEndpoint]
(Int -> ReadS UpdateEndpoint)
-> ReadS [UpdateEndpoint]
-> ReadPrec UpdateEndpoint
-> ReadPrec [UpdateEndpoint]
-> Read UpdateEndpoint
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateEndpoint]
$creadListPrec :: ReadPrec [UpdateEndpoint]
readPrec :: ReadPrec UpdateEndpoint
$creadPrec :: ReadPrec UpdateEndpoint
readList :: ReadS [UpdateEndpoint]
$creadList :: ReadS [UpdateEndpoint]
readsPrec :: Int -> ReadS UpdateEndpoint
$creadsPrec :: Int -> ReadS UpdateEndpoint
Prelude.Read, Int -> UpdateEndpoint -> ShowS
[UpdateEndpoint] -> ShowS
UpdateEndpoint -> String
(Int -> UpdateEndpoint -> ShowS)
-> (UpdateEndpoint -> String)
-> ([UpdateEndpoint] -> ShowS)
-> Show UpdateEndpoint
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateEndpoint] -> ShowS
$cshowList :: [UpdateEndpoint] -> ShowS
show :: UpdateEndpoint -> String
$cshow :: UpdateEndpoint -> String
showsPrec :: Int -> UpdateEndpoint -> ShowS
$cshowsPrec :: Int -> UpdateEndpoint -> ShowS
Prelude.Show, (forall x. UpdateEndpoint -> Rep UpdateEndpoint x)
-> (forall x. Rep UpdateEndpoint x -> UpdateEndpoint)
-> Generic UpdateEndpoint
forall x. Rep UpdateEndpoint x -> UpdateEndpoint
forall x. UpdateEndpoint -> Rep UpdateEndpoint x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateEndpoint x -> UpdateEndpoint
$cfrom :: forall x. UpdateEndpoint -> Rep UpdateEndpoint x
Prelude.Generic)

-- |
-- Create a value of 'UpdateEndpoint' 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:
--
-- 'desiredModelArn', 'updateEndpoint_desiredModelArn' - The ARN of the new model to use when updating an existing endpoint.
--
-- 'desiredInferenceUnits', 'updateEndpoint_desiredInferenceUnits' - The desired number of inference units to be used by the model using this
-- endpoint. Each inference unit represents of a throughput of 100
-- characters per second.
--
-- 'desiredDataAccessRoleArn', 'updateEndpoint_desiredDataAccessRoleArn' - Data access role ARN to use in case the new model is encrypted with a
-- customer CMK.
--
-- 'endpointArn', 'updateEndpoint_endpointArn' - The Amazon Resource Number (ARN) of the endpoint being updated.
newUpdateEndpoint ::
  -- | 'endpointArn'
  Prelude.Text ->
  UpdateEndpoint
newUpdateEndpoint :: Text -> UpdateEndpoint
newUpdateEndpoint Text
pEndpointArn_ =
  UpdateEndpoint' :: Maybe Text -> Maybe Natural -> Maybe Text -> Text -> UpdateEndpoint
UpdateEndpoint'
    { $sel:desiredModelArn:UpdateEndpoint' :: Maybe Text
desiredModelArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:desiredInferenceUnits:UpdateEndpoint' :: Maybe Natural
desiredInferenceUnits = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:desiredDataAccessRoleArn:UpdateEndpoint' :: Maybe Text
desiredDataAccessRoleArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpointArn:UpdateEndpoint' :: Text
endpointArn = Text
pEndpointArn_
    }

-- | The ARN of the new model to use when updating an existing endpoint.
updateEndpoint_desiredModelArn :: Lens.Lens' UpdateEndpoint (Prelude.Maybe Prelude.Text)
updateEndpoint_desiredModelArn :: (Maybe Text -> f (Maybe Text))
-> UpdateEndpoint -> f UpdateEndpoint
updateEndpoint_desiredModelArn = (UpdateEndpoint -> Maybe Text)
-> (UpdateEndpoint -> Maybe Text -> UpdateEndpoint)
-> Lens UpdateEndpoint UpdateEndpoint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpoint' {Maybe Text
desiredModelArn :: Maybe Text
$sel:desiredModelArn:UpdateEndpoint' :: UpdateEndpoint -> Maybe Text
desiredModelArn} -> Maybe Text
desiredModelArn) (\s :: UpdateEndpoint
s@UpdateEndpoint' {} Maybe Text
a -> UpdateEndpoint
s {$sel:desiredModelArn:UpdateEndpoint' :: Maybe Text
desiredModelArn = Maybe Text
a} :: UpdateEndpoint)

-- | The desired number of inference units to be used by the model using this
-- endpoint. Each inference unit represents of a throughput of 100
-- characters per second.
updateEndpoint_desiredInferenceUnits :: Lens.Lens' UpdateEndpoint (Prelude.Maybe Prelude.Natural)
updateEndpoint_desiredInferenceUnits :: (Maybe Natural -> f (Maybe Natural))
-> UpdateEndpoint -> f UpdateEndpoint
updateEndpoint_desiredInferenceUnits = (UpdateEndpoint -> Maybe Natural)
-> (UpdateEndpoint -> Maybe Natural -> UpdateEndpoint)
-> Lens
     UpdateEndpoint UpdateEndpoint (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpoint' {Maybe Natural
desiredInferenceUnits :: Maybe Natural
$sel:desiredInferenceUnits:UpdateEndpoint' :: UpdateEndpoint -> Maybe Natural
desiredInferenceUnits} -> Maybe Natural
desiredInferenceUnits) (\s :: UpdateEndpoint
s@UpdateEndpoint' {} Maybe Natural
a -> UpdateEndpoint
s {$sel:desiredInferenceUnits:UpdateEndpoint' :: Maybe Natural
desiredInferenceUnits = Maybe Natural
a} :: UpdateEndpoint)

-- | Data access role ARN to use in case the new model is encrypted with a
-- customer CMK.
updateEndpoint_desiredDataAccessRoleArn :: Lens.Lens' UpdateEndpoint (Prelude.Maybe Prelude.Text)
updateEndpoint_desiredDataAccessRoleArn :: (Maybe Text -> f (Maybe Text))
-> UpdateEndpoint -> f UpdateEndpoint
updateEndpoint_desiredDataAccessRoleArn = (UpdateEndpoint -> Maybe Text)
-> (UpdateEndpoint -> Maybe Text -> UpdateEndpoint)
-> Lens UpdateEndpoint UpdateEndpoint (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpoint' {Maybe Text
desiredDataAccessRoleArn :: Maybe Text
$sel:desiredDataAccessRoleArn:UpdateEndpoint' :: UpdateEndpoint -> Maybe Text
desiredDataAccessRoleArn} -> Maybe Text
desiredDataAccessRoleArn) (\s :: UpdateEndpoint
s@UpdateEndpoint' {} Maybe Text
a -> UpdateEndpoint
s {$sel:desiredDataAccessRoleArn:UpdateEndpoint' :: Maybe Text
desiredDataAccessRoleArn = Maybe Text
a} :: UpdateEndpoint)

-- | The Amazon Resource Number (ARN) of the endpoint being updated.
updateEndpoint_endpointArn :: Lens.Lens' UpdateEndpoint Prelude.Text
updateEndpoint_endpointArn :: (Text -> f Text) -> UpdateEndpoint -> f UpdateEndpoint
updateEndpoint_endpointArn = (UpdateEndpoint -> Text)
-> (UpdateEndpoint -> Text -> UpdateEndpoint)
-> Lens UpdateEndpoint UpdateEndpoint Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateEndpoint' {Text
endpointArn :: Text
$sel:endpointArn:UpdateEndpoint' :: UpdateEndpoint -> Text
endpointArn} -> Text
endpointArn) (\s :: UpdateEndpoint
s@UpdateEndpoint' {} Text
a -> UpdateEndpoint
s {$sel:endpointArn:UpdateEndpoint' :: Text
endpointArn = Text
a} :: UpdateEndpoint)

instance Core.AWSRequest UpdateEndpoint where
  type
    AWSResponse UpdateEndpoint =
      UpdateEndpointResponse
  request :: UpdateEndpoint -> Request UpdateEndpoint
request = Service -> UpdateEndpoint -> Request UpdateEndpoint
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateEndpoint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateEndpoint)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse UpdateEndpoint))
-> Logger
-> Service
-> Proxy UpdateEndpoint
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateEndpoint)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> UpdateEndpointResponse
UpdateEndpointResponse'
            (Int -> UpdateEndpointResponse)
-> Either String Int -> Either String UpdateEndpointResponse
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))
      )

instance Prelude.Hashable UpdateEndpoint

instance Prelude.NFData UpdateEndpoint

instance Core.ToHeaders UpdateEndpoint where
  toHeaders :: UpdateEndpoint -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateEndpoint -> 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
"Comprehend_20171127.UpdateEndpoint" ::
                          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 UpdateEndpoint where
  toJSON :: UpdateEndpoint -> Value
toJSON UpdateEndpoint' {Maybe Natural
Maybe Text
Text
endpointArn :: Text
desiredDataAccessRoleArn :: Maybe Text
desiredInferenceUnits :: Maybe Natural
desiredModelArn :: Maybe Text
$sel:endpointArn:UpdateEndpoint' :: UpdateEndpoint -> Text
$sel:desiredDataAccessRoleArn:UpdateEndpoint' :: UpdateEndpoint -> Maybe Text
$sel:desiredInferenceUnits:UpdateEndpoint' :: UpdateEndpoint -> Maybe Natural
$sel:desiredModelArn:UpdateEndpoint' :: UpdateEndpoint -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"DesiredModelArn" 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
desiredModelArn,
            (Text
"DesiredInferenceUnits" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
desiredInferenceUnits,
            (Text
"DesiredDataAccessRoleArn" 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
desiredDataAccessRoleArn,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EndpointArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
endpointArn)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateEndpointResponse' 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', 'updateEndpointResponse_httpStatus' - The response's http status code.
newUpdateEndpointResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateEndpointResponse
newUpdateEndpointResponse :: Int -> UpdateEndpointResponse
newUpdateEndpointResponse Int
pHttpStatus_ =
  UpdateEndpointResponse' :: Int -> UpdateEndpointResponse
UpdateEndpointResponse' {$sel:httpStatus:UpdateEndpointResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData UpdateEndpointResponse