{-# 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-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 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_registryName,
    updateRegistryResponse_registryArn,
    updateRegistryResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.Glue.Types
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:/ '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
(UpdateRegistry -> UpdateRegistry -> Bool)
-> (UpdateRegistry -> UpdateRegistry -> Bool) -> Eq UpdateRegistry
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]
(Int -> ReadS UpdateRegistry)
-> ReadS [UpdateRegistry]
-> ReadPrec UpdateRegistry
-> ReadPrec [UpdateRegistry]
-> Read 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
(Int -> UpdateRegistry -> ShowS)
-> (UpdateRegistry -> String)
-> ([UpdateRegistry] -> ShowS)
-> Show UpdateRegistry
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. UpdateRegistry -> Rep UpdateRegistry x)
-> (forall x. Rep UpdateRegistry x -> UpdateRegistry)
-> Generic UpdateRegistry
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' :: RegistryId -> Text -> UpdateRegistry
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 :: (RegistryId -> f RegistryId) -> UpdateRegistry -> f UpdateRegistry
updateRegistry_registryId = (UpdateRegistry -> RegistryId)
-> (UpdateRegistry -> RegistryId -> UpdateRegistry)
-> Lens UpdateRegistry UpdateRegistry RegistryId 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 :: (Text -> f Text) -> UpdateRegistry -> f UpdateRegistry
updateRegistry_description = (UpdateRegistry -> Text)
-> (UpdateRegistry -> Text -> UpdateRegistry)
-> Lens UpdateRegistry UpdateRegistry Text Text
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 :: UpdateRegistry -> Request UpdateRegistry
request = Service -> UpdateRegistry -> Request UpdateRegistry
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateRegistry
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRegistry)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateRegistry))
-> Logger
-> Service
-> Proxy UpdateRegistry
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRegistry)))
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 ->
          Maybe Text -> Maybe Text -> Int -> UpdateRegistryResponse
UpdateRegistryResponse'
            (Maybe Text -> Maybe Text -> Int -> UpdateRegistryResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> UpdateRegistryResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RegistryName")
            Either String (Maybe Text -> Int -> UpdateRegistryResponse)
-> Either String (Maybe Text)
-> Either String (Int -> UpdateRegistryResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"RegistryArn")
            Either String (Int -> UpdateRegistryResponse)
-> Either String Int -> Either String UpdateRegistryResponse
forall (f :: * -> *) a b. Applicative f => 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 UpdateRegistry

instance Prelude.NFData UpdateRegistry

instance Core.ToHeaders UpdateRegistry where
  toHeaders :: UpdateRegistry -> ResponseHeaders
toHeaders =
    ResponseHeaders -> UpdateRegistry -> 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
"AWSGlue.UpdateRegistry" :: 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 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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RegistryId" Text -> RegistryId -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RegistryId
registryId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
description)
          ]
      )

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

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

-- | /See:/ 'newUpdateRegistryResponse' smart constructor.
data UpdateRegistryResponse = UpdateRegistryResponse'
  { -- | The name of the updated registry.
    UpdateRegistryResponse -> Maybe Text
registryName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource name (ARN) of the updated registry.
    UpdateRegistryResponse -> Maybe Text
registryArn :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateRegistryResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateRegistryResponse -> UpdateRegistryResponse -> Bool
(UpdateRegistryResponse -> UpdateRegistryResponse -> Bool)
-> (UpdateRegistryResponse -> UpdateRegistryResponse -> Bool)
-> Eq UpdateRegistryResponse
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]
(Int -> ReadS UpdateRegistryResponse)
-> ReadS [UpdateRegistryResponse]
-> ReadPrec UpdateRegistryResponse
-> ReadPrec [UpdateRegistryResponse]
-> Read 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
(Int -> UpdateRegistryResponse -> ShowS)
-> (UpdateRegistryResponse -> String)
-> ([UpdateRegistryResponse] -> ShowS)
-> Show UpdateRegistryResponse
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. UpdateRegistryResponse -> Rep UpdateRegistryResponse x)
-> (forall x.
    Rep UpdateRegistryResponse x -> UpdateRegistryResponse)
-> Generic UpdateRegistryResponse
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:
--
-- 'registryName', 'updateRegistryResponse_registryName' - The name of the updated registry.
--
-- 'registryArn', 'updateRegistryResponse_registryArn' - The Amazon Resource name (ARN) 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' :: Maybe Text -> Maybe Text -> Int -> UpdateRegistryResponse
UpdateRegistryResponse'
    { $sel:registryName:UpdateRegistryResponse' :: Maybe Text
registryName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:registryArn:UpdateRegistryResponse' :: Maybe Text
registryArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateRegistryResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The name of the updated registry.
updateRegistryResponse_registryName :: Lens.Lens' UpdateRegistryResponse (Prelude.Maybe Prelude.Text)
updateRegistryResponse_registryName :: (Maybe Text -> f (Maybe Text))
-> UpdateRegistryResponse -> f UpdateRegistryResponse
updateRegistryResponse_registryName = (UpdateRegistryResponse -> Maybe Text)
-> (UpdateRegistryResponse -> Maybe Text -> UpdateRegistryResponse)
-> Lens
     UpdateRegistryResponse
     UpdateRegistryResponse
     (Maybe Text)
     (Maybe Text)
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 Amazon Resource name (ARN) of the updated registry.
updateRegistryResponse_registryArn :: Lens.Lens' UpdateRegistryResponse (Prelude.Maybe Prelude.Text)
updateRegistryResponse_registryArn :: (Maybe Text -> f (Maybe Text))
-> UpdateRegistryResponse -> f UpdateRegistryResponse
updateRegistryResponse_registryArn = (UpdateRegistryResponse -> Maybe Text)
-> (UpdateRegistryResponse -> Maybe Text -> UpdateRegistryResponse)
-> Lens
     UpdateRegistryResponse
     UpdateRegistryResponse
     (Maybe Text)
     (Maybe Text)
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 response's http status code.
updateRegistryResponse_httpStatus :: Lens.Lens' UpdateRegistryResponse Prelude.Int
updateRegistryResponse_httpStatus :: (Int -> f Int)
-> UpdateRegistryResponse -> f UpdateRegistryResponse
updateRegistryResponse_httpStatus = (UpdateRegistryResponse -> Int)
-> (UpdateRegistryResponse -> Int -> UpdateRegistryResponse)
-> Lens UpdateRegistryResponse UpdateRegistryResponse Int Int
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