{-# 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.APIGateway.UpdateRestApi
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Changes information about the specified API.
module Amazonka.APIGateway.UpdateRestApi
  ( -- * Creating a Request
    UpdateRestApi (..),
    newUpdateRestApi,

    -- * Request Lenses
    updateRestApi_patchOperations,
    updateRestApi_restApiId,

    -- * Destructuring the Response
    RestApi (..),
    newRestApi,

    -- * Response Lenses
    restApi_apiKeySource,
    restApi_binaryMediaTypes,
    restApi_createdDate,
    restApi_description,
    restApi_disableExecuteApiEndpoint,
    restApi_endpointConfiguration,
    restApi_id,
    restApi_minimumCompressionSize,
    restApi_name,
    restApi_policy,
    restApi_tags,
    restApi_version,
    restApi_warnings,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | Request to update an existing RestApi resource in your collection.
--
-- /See:/ 'newUpdateRestApi' smart constructor.
data UpdateRestApi = UpdateRestApi'
  { -- | For more information about supported patch operations, see
    -- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
    UpdateRestApi -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | The string identifier of the associated RestApi.
    UpdateRestApi -> Text
restApiId :: Prelude.Text
  }
  deriving (UpdateRestApi -> UpdateRestApi -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRestApi -> UpdateRestApi -> Bool
$c/= :: UpdateRestApi -> UpdateRestApi -> Bool
== :: UpdateRestApi -> UpdateRestApi -> Bool
$c== :: UpdateRestApi -> UpdateRestApi -> Bool
Prelude.Eq, ReadPrec [UpdateRestApi]
ReadPrec UpdateRestApi
Int -> ReadS UpdateRestApi
ReadS [UpdateRestApi]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRestApi]
$creadListPrec :: ReadPrec [UpdateRestApi]
readPrec :: ReadPrec UpdateRestApi
$creadPrec :: ReadPrec UpdateRestApi
readList :: ReadS [UpdateRestApi]
$creadList :: ReadS [UpdateRestApi]
readsPrec :: Int -> ReadS UpdateRestApi
$creadsPrec :: Int -> ReadS UpdateRestApi
Prelude.Read, Int -> UpdateRestApi -> ShowS
[UpdateRestApi] -> ShowS
UpdateRestApi -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRestApi] -> ShowS
$cshowList :: [UpdateRestApi] -> ShowS
show :: UpdateRestApi -> String
$cshow :: UpdateRestApi -> String
showsPrec :: Int -> UpdateRestApi -> ShowS
$cshowsPrec :: Int -> UpdateRestApi -> ShowS
Prelude.Show, forall x. Rep UpdateRestApi x -> UpdateRestApi
forall x. UpdateRestApi -> Rep UpdateRestApi x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRestApi x -> UpdateRestApi
$cfrom :: forall x. UpdateRestApi -> Rep UpdateRestApi x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRestApi' 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:
--
-- 'patchOperations', 'updateRestApi_patchOperations' - For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
--
-- 'restApiId', 'updateRestApi_restApiId' - The string identifier of the associated RestApi.
newUpdateRestApi ::
  -- | 'restApiId'
  Prelude.Text ->
  UpdateRestApi
newUpdateRestApi :: Text -> UpdateRestApi
newUpdateRestApi Text
pRestApiId_ =
  UpdateRestApi'
    { $sel:patchOperations:UpdateRestApi' :: Maybe [PatchOperation]
patchOperations = forall a. Maybe a
Prelude.Nothing,
      $sel:restApiId:UpdateRestApi' :: Text
restApiId = Text
pRestApiId_
    }

-- | For more information about supported patch operations, see
-- <https://docs.aws.amazon.com/apigateway/latest/api/patch-operations.html Patch Operations>.
updateRestApi_patchOperations :: Lens.Lens' UpdateRestApi (Prelude.Maybe [PatchOperation])
updateRestApi_patchOperations :: Lens' UpdateRestApi (Maybe [PatchOperation])
updateRestApi_patchOperations = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRestApi' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateRestApi' :: UpdateRestApi -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateRestApi
s@UpdateRestApi' {} Maybe [PatchOperation]
a -> UpdateRestApi
s {$sel:patchOperations:UpdateRestApi' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateRestApi) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The string identifier of the associated RestApi.
updateRestApi_restApiId :: Lens.Lens' UpdateRestApi Prelude.Text
updateRestApi_restApiId :: Lens' UpdateRestApi Text
updateRestApi_restApiId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRestApi' {Text
restApiId :: Text
$sel:restApiId:UpdateRestApi' :: UpdateRestApi -> Text
restApiId} -> Text
restApiId) (\s :: UpdateRestApi
s@UpdateRestApi' {} Text
a -> UpdateRestApi
s {$sel:restApiId:UpdateRestApi' :: Text
restApiId = Text
a} :: UpdateRestApi)

instance Core.AWSRequest UpdateRestApi where
  type AWSResponse UpdateRestApi = RestApi
  request :: (Service -> Service) -> UpdateRestApi -> Request UpdateRestApi
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateRestApi
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRestApi)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      (\Int
s ResponseHeaders
h Object
x -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable UpdateRestApi where
  hashWithSalt :: Int -> UpdateRestApi -> Int
hashWithSalt Int
_salt UpdateRestApi' {Maybe [PatchOperation]
Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:restApiId:UpdateRestApi' :: UpdateRestApi -> Text
$sel:patchOperations:UpdateRestApi' :: UpdateRestApi -> Maybe [PatchOperation]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [PatchOperation]
patchOperations
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId

instance Prelude.NFData UpdateRestApi where
  rnf :: UpdateRestApi -> ()
rnf UpdateRestApi' {Maybe [PatchOperation]
Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:restApiId:UpdateRestApi' :: UpdateRestApi -> Text
$sel:patchOperations:UpdateRestApi' :: UpdateRestApi -> Maybe [PatchOperation]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PatchOperation]
patchOperations
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId

instance Data.ToHeaders UpdateRestApi where
  toHeaders :: UpdateRestApi -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToJSON UpdateRestApi where
  toJSON :: UpdateRestApi -> Value
toJSON UpdateRestApi' {Maybe [PatchOperation]
Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:restApiId:UpdateRestApi' :: UpdateRestApi -> Text
$sel:patchOperations:UpdateRestApi' :: UpdateRestApi -> Maybe [PatchOperation]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"patchOperations" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [PatchOperation]
patchOperations
          ]
      )

instance Data.ToPath UpdateRestApi where
  toPath :: UpdateRestApi -> ByteString
toPath UpdateRestApi' {Maybe [PatchOperation]
Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:restApiId:UpdateRestApi' :: UpdateRestApi -> Text
$sel:patchOperations:UpdateRestApi' :: UpdateRestApi -> Maybe [PatchOperation]
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/restapis/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId]

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