{-# 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.Glue.UpdateRegistry
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates an existing registry which is used to hold a collection of
-- schemas. The updated properties relate to the registry, and do not
-- modify any of the schemas within the registry.
module Amazonka.Glue.UpdateRegistry
  ( -- * Creating a Request
    UpdateRegistry (..),
    newUpdateRegistry,

    -- * Request Lenses
    updateRegistry_registryId,
    updateRegistry_description,

    -- * Destructuring the Response
    UpdateRegistryResponse (..),
    newUpdateRegistryResponse,

    -- * Response Lenses
    updateRegistryResponse_registryArn,
    updateRegistryResponse_registryName,
    updateRegistryResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateRegistry' smart constructor.
data UpdateRegistry = UpdateRegistry'
  { -- | This is a wrapper structure that may contain the registry name and
    -- Amazon Resource Name (ARN).
    UpdateRegistry -> RegistryId
registryId :: RegistryId,
    -- | A description of the registry. If description is not provided, this
    -- field will not be updated.
    UpdateRegistry -> Text
description :: Prelude.Text
  }
  deriving (UpdateRegistry -> UpdateRegistry -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRegistry -> UpdateRegistry -> Bool
$c/= :: UpdateRegistry -> UpdateRegistry -> Bool
== :: UpdateRegistry -> UpdateRegistry -> Bool
$c== :: UpdateRegistry -> UpdateRegistry -> Bool
Prelude.Eq, ReadPrec [UpdateRegistry]
ReadPrec UpdateRegistry
Int -> ReadS UpdateRegistry
ReadS [UpdateRegistry]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRegistry]
$creadListPrec :: ReadPrec [UpdateRegistry]
readPrec :: ReadPrec UpdateRegistry
$creadPrec :: ReadPrec UpdateRegistry
readList :: ReadS [UpdateRegistry]
$creadList :: ReadS [UpdateRegistry]
readsPrec :: Int -> ReadS UpdateRegistry
$creadsPrec :: Int -> ReadS UpdateRegistry
Prelude.Read, Int -> UpdateRegistry -> ShowS
[UpdateRegistry] -> ShowS
UpdateRegistry -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRegistry] -> ShowS
$cshowList :: [UpdateRegistry] -> ShowS
show :: UpdateRegistry -> String
$cshow :: UpdateRegistry -> String
showsPrec :: Int -> UpdateRegistry -> ShowS
$cshowsPrec :: Int -> UpdateRegistry -> ShowS
Prelude.Show, forall x. Rep UpdateRegistry x -> UpdateRegistry
forall x. UpdateRegistry -> Rep UpdateRegistry x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRegistry x -> UpdateRegistry
$cfrom :: forall x. UpdateRegistry -> Rep UpdateRegistry x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRegistry' 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:
--
-- 'registryId', 'updateRegistry_registryId' - This is a wrapper structure that may contain the registry name and
-- Amazon Resource Name (ARN).
--
-- 'description', 'updateRegistry_description' - A description of the registry. If description is not provided, this
-- field will not be updated.
newUpdateRegistry ::
  -- | 'registryId'
  RegistryId ->
  -- | 'description'
  Prelude.Text ->
  UpdateRegistry
newUpdateRegistry :: RegistryId -> Text -> UpdateRegistry
newUpdateRegistry RegistryId
pRegistryId_ Text
pDescription_ =
  UpdateRegistry'
    { $sel:registryId:UpdateRegistry' :: RegistryId
registryId = RegistryId
pRegistryId_,
      $sel:description:UpdateRegistry' :: Text
description = Text
pDescription_
    }

-- | This is a wrapper structure that may contain the registry name and
-- Amazon Resource Name (ARN).
updateRegistry_registryId :: Lens.Lens' UpdateRegistry RegistryId
updateRegistry_registryId :: Lens' UpdateRegistry RegistryId
updateRegistry_registryId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRegistry' {RegistryId
registryId :: RegistryId
$sel:registryId:UpdateRegistry' :: UpdateRegistry -> RegistryId
registryId} -> RegistryId
registryId) (\s :: UpdateRegistry
s@UpdateRegistry' {} RegistryId
a -> UpdateRegistry
s {$sel:registryId:UpdateRegistry' :: RegistryId
registryId = RegistryId
a} :: UpdateRegistry)

-- | A description of the registry. If description is not provided, this
-- field will not be updated.
updateRegistry_description :: Lens.Lens' UpdateRegistry Prelude.Text
updateRegistry_description :: Lens' UpdateRegistry Text
updateRegistry_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRegistry' {Text
description :: Text
$sel:description:UpdateRegistry' :: UpdateRegistry -> Text
description} -> Text
description) (\s :: UpdateRegistry
s@UpdateRegistry' {} Text
a -> UpdateRegistry
s {$sel:description:UpdateRegistry' :: Text
description = Text
a} :: UpdateRegistry)

instance Core.AWSRequest UpdateRegistry where
  type
    AWSResponse UpdateRegistry =
      UpdateRegistryResponse
  request :: (Service -> Service) -> UpdateRegistry -> Request UpdateRegistry
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateRegistry
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRegistry)))
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 ->
          Maybe Text -> Maybe Text -> Int -> UpdateRegistryResponse
UpdateRegistryResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RegistryArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"RegistryName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateRegistry where
  hashWithSalt :: Int -> UpdateRegistry -> Int
hashWithSalt Int
_salt UpdateRegistry' {Text
RegistryId
description :: Text
registryId :: RegistryId
$sel:description:UpdateRegistry' :: UpdateRegistry -> Text
$sel:registryId:UpdateRegistry' :: UpdateRegistry -> RegistryId
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RegistryId
registryId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
description

instance Prelude.NFData UpdateRegistry where
  rnf :: UpdateRegistry -> ()
rnf UpdateRegistry' {Text
RegistryId
description :: Text
registryId :: RegistryId
$sel:description:UpdateRegistry' :: UpdateRegistry -> Text
$sel:registryId:UpdateRegistry' :: UpdateRegistry -> RegistryId
..} =
    forall a. NFData a => a -> ()
Prelude.rnf RegistryId
registryId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
description

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

instance Data.ToJSON UpdateRegistry where
  toJSON :: UpdateRegistry -> Value
toJSON UpdateRegistry' {Text
RegistryId
description :: Text
registryId :: RegistryId
$sel:description:UpdateRegistry' :: UpdateRegistry -> Text
$sel:registryId:UpdateRegistry' :: UpdateRegistry -> RegistryId
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"RegistryId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RegistryId
registryId),
            forall a. a -> Maybe a
Prelude.Just (Key
"Description" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
description)
          ]
      )

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

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

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

-- |
-- Create a value of 'UpdateRegistryResponse' 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:
--
-- 'registryArn', 'updateRegistryResponse_registryArn' - The Amazon Resource name (ARN) of the updated registry.
--
-- 'registryName', 'updateRegistryResponse_registryName' - The name of the updated registry.
--
-- 'httpStatus', 'updateRegistryResponse_httpStatus' - The response's http status code.
newUpdateRegistryResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateRegistryResponse
newUpdateRegistryResponse :: Int -> UpdateRegistryResponse
newUpdateRegistryResponse Int
pHttpStatus_ =
  UpdateRegistryResponse'
    { $sel:registryArn:UpdateRegistryResponse' :: Maybe Text
registryArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:registryName:UpdateRegistryResponse' :: Maybe Text
registryName = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateRegistryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource name (ARN) of the updated registry.
updateRegistryResponse_registryArn :: Lens.Lens' UpdateRegistryResponse (Prelude.Maybe Prelude.Text)
updateRegistryResponse_registryArn :: Lens' UpdateRegistryResponse (Maybe Text)
updateRegistryResponse_registryArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRegistryResponse' {Maybe Text
registryArn :: Maybe Text
$sel:registryArn:UpdateRegistryResponse' :: UpdateRegistryResponse -> Maybe Text
registryArn} -> Maybe Text
registryArn) (\s :: UpdateRegistryResponse
s@UpdateRegistryResponse' {} Maybe Text
a -> UpdateRegistryResponse
s {$sel:registryArn:UpdateRegistryResponse' :: Maybe Text
registryArn = Maybe Text
a} :: UpdateRegistryResponse)

-- | The name of the updated registry.
updateRegistryResponse_registryName :: Lens.Lens' UpdateRegistryResponse (Prelude.Maybe Prelude.Text)
updateRegistryResponse_registryName :: Lens' UpdateRegistryResponse (Maybe Text)
updateRegistryResponse_registryName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRegistryResponse' {Maybe Text
registryName :: Maybe Text
$sel:registryName:UpdateRegistryResponse' :: UpdateRegistryResponse -> Maybe Text
registryName} -> Maybe Text
registryName) (\s :: UpdateRegistryResponse
s@UpdateRegistryResponse' {} Maybe Text
a -> UpdateRegistryResponse
s {$sel:registryName:UpdateRegistryResponse' :: Maybe Text
registryName = Maybe Text
a} :: UpdateRegistryResponse)

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

instance Prelude.NFData UpdateRegistryResponse where
  rnf :: UpdateRegistryResponse -> ()
rnf UpdateRegistryResponse' {Int
Maybe Text
httpStatus :: Int
registryName :: Maybe Text
registryArn :: Maybe Text
$sel:httpStatus:UpdateRegistryResponse' :: UpdateRegistryResponse -> Int
$sel:registryName:UpdateRegistryResponse' :: UpdateRegistryResponse -> Maybe Text
$sel:registryArn:UpdateRegistryResponse' :: UpdateRegistryResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
registryArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
registryName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus