{-# 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.Route53AutoNaming.UpdateHttpNamespace
-- 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 HTTP namespace.
module Amazonka.Route53AutoNaming.UpdateHttpNamespace
  ( -- * Creating a Request
    UpdateHttpNamespace (..),
    newUpdateHttpNamespace,

    -- * Request Lenses
    updateHttpNamespace_updaterRequestId,
    updateHttpNamespace_id,
    updateHttpNamespace_namespace,

    -- * Destructuring the Response
    UpdateHttpNamespaceResponse (..),
    newUpdateHttpNamespaceResponse,

    -- * Response Lenses
    updateHttpNamespaceResponse_operationId,
    updateHttpNamespaceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newUpdateHttpNamespace' smart constructor.
data UpdateHttpNamespace = UpdateHttpNamespace'
  { -- | A unique string that identifies the request and that allows failed
    -- @UpdateHttpNamespace@ requests to be retried without the risk of running
    -- the operation twice. @UpdaterRequestId@ can be any unique string (for
    -- example, a date\/timestamp).
    UpdateHttpNamespace -> Maybe Text
updaterRequestId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the namespace that you want to update.
    UpdateHttpNamespace -> Text
id :: Prelude.Text,
    -- | Updated properties for the the HTTP namespace.
    UpdateHttpNamespace -> HttpNamespaceChange
namespace :: HttpNamespaceChange
  }
  deriving (UpdateHttpNamespace -> UpdateHttpNamespace -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateHttpNamespace -> UpdateHttpNamespace -> Bool
$c/= :: UpdateHttpNamespace -> UpdateHttpNamespace -> Bool
== :: UpdateHttpNamespace -> UpdateHttpNamespace -> Bool
$c== :: UpdateHttpNamespace -> UpdateHttpNamespace -> Bool
Prelude.Eq, ReadPrec [UpdateHttpNamespace]
ReadPrec UpdateHttpNamespace
Int -> ReadS UpdateHttpNamespace
ReadS [UpdateHttpNamespace]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateHttpNamespace]
$creadListPrec :: ReadPrec [UpdateHttpNamespace]
readPrec :: ReadPrec UpdateHttpNamespace
$creadPrec :: ReadPrec UpdateHttpNamespace
readList :: ReadS [UpdateHttpNamespace]
$creadList :: ReadS [UpdateHttpNamespace]
readsPrec :: Int -> ReadS UpdateHttpNamespace
$creadsPrec :: Int -> ReadS UpdateHttpNamespace
Prelude.Read, Int -> UpdateHttpNamespace -> ShowS
[UpdateHttpNamespace] -> ShowS
UpdateHttpNamespace -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateHttpNamespace] -> ShowS
$cshowList :: [UpdateHttpNamespace] -> ShowS
show :: UpdateHttpNamespace -> String
$cshow :: UpdateHttpNamespace -> String
showsPrec :: Int -> UpdateHttpNamespace -> ShowS
$cshowsPrec :: Int -> UpdateHttpNamespace -> ShowS
Prelude.Show, forall x. Rep UpdateHttpNamespace x -> UpdateHttpNamespace
forall x. UpdateHttpNamespace -> Rep UpdateHttpNamespace x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateHttpNamespace x -> UpdateHttpNamespace
$cfrom :: forall x. UpdateHttpNamespace -> Rep UpdateHttpNamespace x
Prelude.Generic)

-- |
-- Create a value of 'UpdateHttpNamespace' 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:
--
-- 'updaterRequestId', 'updateHttpNamespace_updaterRequestId' - A unique string that identifies the request and that allows failed
-- @UpdateHttpNamespace@ requests to be retried without the risk of running
-- the operation twice. @UpdaterRequestId@ can be any unique string (for
-- example, a date\/timestamp).
--
-- 'id', 'updateHttpNamespace_id' - The ID of the namespace that you want to update.
--
-- 'namespace', 'updateHttpNamespace_namespace' - Updated properties for the the HTTP namespace.
newUpdateHttpNamespace ::
  -- | 'id'
  Prelude.Text ->
  -- | 'namespace'
  HttpNamespaceChange ->
  UpdateHttpNamespace
newUpdateHttpNamespace :: Text -> HttpNamespaceChange -> UpdateHttpNamespace
newUpdateHttpNamespace Text
pId_ HttpNamespaceChange
pNamespace_ =
  UpdateHttpNamespace'
    { $sel:updaterRequestId:UpdateHttpNamespace' :: Maybe Text
updaterRequestId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:id:UpdateHttpNamespace' :: Text
id = Text
pId_,
      $sel:namespace:UpdateHttpNamespace' :: HttpNamespaceChange
namespace = HttpNamespaceChange
pNamespace_
    }

-- | A unique string that identifies the request and that allows failed
-- @UpdateHttpNamespace@ requests to be retried without the risk of running
-- the operation twice. @UpdaterRequestId@ can be any unique string (for
-- example, a date\/timestamp).
updateHttpNamespace_updaterRequestId :: Lens.Lens' UpdateHttpNamespace (Prelude.Maybe Prelude.Text)
updateHttpNamespace_updaterRequestId :: Lens' UpdateHttpNamespace (Maybe Text)
updateHttpNamespace_updaterRequestId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHttpNamespace' {Maybe Text
updaterRequestId :: Maybe Text
$sel:updaterRequestId:UpdateHttpNamespace' :: UpdateHttpNamespace -> Maybe Text
updaterRequestId} -> Maybe Text
updaterRequestId) (\s :: UpdateHttpNamespace
s@UpdateHttpNamespace' {} Maybe Text
a -> UpdateHttpNamespace
s {$sel:updaterRequestId:UpdateHttpNamespace' :: Maybe Text
updaterRequestId = Maybe Text
a} :: UpdateHttpNamespace)

-- | The ID of the namespace that you want to update.
updateHttpNamespace_id :: Lens.Lens' UpdateHttpNamespace Prelude.Text
updateHttpNamespace_id :: Lens' UpdateHttpNamespace Text
updateHttpNamespace_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHttpNamespace' {Text
id :: Text
$sel:id:UpdateHttpNamespace' :: UpdateHttpNamespace -> Text
id} -> Text
id) (\s :: UpdateHttpNamespace
s@UpdateHttpNamespace' {} Text
a -> UpdateHttpNamespace
s {$sel:id:UpdateHttpNamespace' :: Text
id = Text
a} :: UpdateHttpNamespace)

-- | Updated properties for the the HTTP namespace.
updateHttpNamespace_namespace :: Lens.Lens' UpdateHttpNamespace HttpNamespaceChange
updateHttpNamespace_namespace :: Lens' UpdateHttpNamespace HttpNamespaceChange
updateHttpNamespace_namespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHttpNamespace' {HttpNamespaceChange
namespace :: HttpNamespaceChange
$sel:namespace:UpdateHttpNamespace' :: UpdateHttpNamespace -> HttpNamespaceChange
namespace} -> HttpNamespaceChange
namespace) (\s :: UpdateHttpNamespace
s@UpdateHttpNamespace' {} HttpNamespaceChange
a -> UpdateHttpNamespace
s {$sel:namespace:UpdateHttpNamespace' :: HttpNamespaceChange
namespace = HttpNamespaceChange
a} :: UpdateHttpNamespace)

instance Core.AWSRequest UpdateHttpNamespace where
  type
    AWSResponse UpdateHttpNamespace =
      UpdateHttpNamespaceResponse
  request :: (Service -> Service)
-> UpdateHttpNamespace -> Request UpdateHttpNamespace
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 UpdateHttpNamespace
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateHttpNamespace)))
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 -> Int -> UpdateHttpNamespaceResponse
UpdateHttpNamespaceResponse'
            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
"OperationId")
            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 UpdateHttpNamespace where
  hashWithSalt :: Int -> UpdateHttpNamespace -> Int
hashWithSalt Int
_salt UpdateHttpNamespace' {Maybe Text
Text
HttpNamespaceChange
namespace :: HttpNamespaceChange
id :: Text
updaterRequestId :: Maybe Text
$sel:namespace:UpdateHttpNamespace' :: UpdateHttpNamespace -> HttpNamespaceChange
$sel:id:UpdateHttpNamespace' :: UpdateHttpNamespace -> Text
$sel:updaterRequestId:UpdateHttpNamespace' :: UpdateHttpNamespace -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
updaterRequestId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` HttpNamespaceChange
namespace

instance Prelude.NFData UpdateHttpNamespace where
  rnf :: UpdateHttpNamespace -> ()
rnf UpdateHttpNamespace' {Maybe Text
Text
HttpNamespaceChange
namespace :: HttpNamespaceChange
id :: Text
updaterRequestId :: Maybe Text
$sel:namespace:UpdateHttpNamespace' :: UpdateHttpNamespace -> HttpNamespaceChange
$sel:id:UpdateHttpNamespace' :: UpdateHttpNamespace -> Text
$sel:updaterRequestId:UpdateHttpNamespace' :: UpdateHttpNamespace -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
updaterRequestId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf HttpNamespaceChange
namespace

instance Data.ToHeaders UpdateHttpNamespace where
  toHeaders :: UpdateHttpNamespace -> 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
"Route53AutoNaming_v20170314.UpdateHttpNamespace" ::
                          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 UpdateHttpNamespace where
  toJSON :: UpdateHttpNamespace -> Value
toJSON UpdateHttpNamespace' {Maybe Text
Text
HttpNamespaceChange
namespace :: HttpNamespaceChange
id :: Text
updaterRequestId :: Maybe Text
$sel:namespace:UpdateHttpNamespace' :: UpdateHttpNamespace -> HttpNamespaceChange
$sel:id:UpdateHttpNamespace' :: UpdateHttpNamespace -> Text
$sel:updaterRequestId:UpdateHttpNamespace' :: UpdateHttpNamespace -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"UpdaterRequestId" 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 Text
updaterRequestId,
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
            forall a. a -> Maybe a
Prelude.Just (Key
"Namespace" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= HttpNamespaceChange
namespace)
          ]
      )

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

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

-- | /See:/ 'newUpdateHttpNamespaceResponse' smart constructor.
data UpdateHttpNamespaceResponse = UpdateHttpNamespaceResponse'
  { -- | A value that you can use to determine whether the request completed
    -- successfully. To get the status of the operation, see
    -- <https://docs.aws.amazon.com/cloud-map/latest/api/API_GetOperation.html GetOperation>.
    UpdateHttpNamespaceResponse -> Maybe Text
operationId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    UpdateHttpNamespaceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateHttpNamespaceResponse -> UpdateHttpNamespaceResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateHttpNamespaceResponse -> UpdateHttpNamespaceResponse -> Bool
$c/= :: UpdateHttpNamespaceResponse -> UpdateHttpNamespaceResponse -> Bool
== :: UpdateHttpNamespaceResponse -> UpdateHttpNamespaceResponse -> Bool
$c== :: UpdateHttpNamespaceResponse -> UpdateHttpNamespaceResponse -> Bool
Prelude.Eq, ReadPrec [UpdateHttpNamespaceResponse]
ReadPrec UpdateHttpNamespaceResponse
Int -> ReadS UpdateHttpNamespaceResponse
ReadS [UpdateHttpNamespaceResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateHttpNamespaceResponse]
$creadListPrec :: ReadPrec [UpdateHttpNamespaceResponse]
readPrec :: ReadPrec UpdateHttpNamespaceResponse
$creadPrec :: ReadPrec UpdateHttpNamespaceResponse
readList :: ReadS [UpdateHttpNamespaceResponse]
$creadList :: ReadS [UpdateHttpNamespaceResponse]
readsPrec :: Int -> ReadS UpdateHttpNamespaceResponse
$creadsPrec :: Int -> ReadS UpdateHttpNamespaceResponse
Prelude.Read, Int -> UpdateHttpNamespaceResponse -> ShowS
[UpdateHttpNamespaceResponse] -> ShowS
UpdateHttpNamespaceResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateHttpNamespaceResponse] -> ShowS
$cshowList :: [UpdateHttpNamespaceResponse] -> ShowS
show :: UpdateHttpNamespaceResponse -> String
$cshow :: UpdateHttpNamespaceResponse -> String
showsPrec :: Int -> UpdateHttpNamespaceResponse -> ShowS
$cshowsPrec :: Int -> UpdateHttpNamespaceResponse -> ShowS
Prelude.Show, forall x.
Rep UpdateHttpNamespaceResponse x -> UpdateHttpNamespaceResponse
forall x.
UpdateHttpNamespaceResponse -> Rep UpdateHttpNamespaceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateHttpNamespaceResponse x -> UpdateHttpNamespaceResponse
$cfrom :: forall x.
UpdateHttpNamespaceResponse -> Rep UpdateHttpNamespaceResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateHttpNamespaceResponse' 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:
--
-- 'operationId', 'updateHttpNamespaceResponse_operationId' - A value that you can use to determine whether the request completed
-- successfully. To get the status of the operation, see
-- <https://docs.aws.amazon.com/cloud-map/latest/api/API_GetOperation.html GetOperation>.
--
-- 'httpStatus', 'updateHttpNamespaceResponse_httpStatus' - The response's http status code.
newUpdateHttpNamespaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateHttpNamespaceResponse
newUpdateHttpNamespaceResponse :: Int -> UpdateHttpNamespaceResponse
newUpdateHttpNamespaceResponse Int
pHttpStatus_ =
  UpdateHttpNamespaceResponse'
    { $sel:operationId:UpdateHttpNamespaceResponse' :: Maybe Text
operationId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateHttpNamespaceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A value that you can use to determine whether the request completed
-- successfully. To get the status of the operation, see
-- <https://docs.aws.amazon.com/cloud-map/latest/api/API_GetOperation.html GetOperation>.
updateHttpNamespaceResponse_operationId :: Lens.Lens' UpdateHttpNamespaceResponse (Prelude.Maybe Prelude.Text)
updateHttpNamespaceResponse_operationId :: Lens' UpdateHttpNamespaceResponse (Maybe Text)
updateHttpNamespaceResponse_operationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateHttpNamespaceResponse' {Maybe Text
operationId :: Maybe Text
$sel:operationId:UpdateHttpNamespaceResponse' :: UpdateHttpNamespaceResponse -> Maybe Text
operationId} -> Maybe Text
operationId) (\s :: UpdateHttpNamespaceResponse
s@UpdateHttpNamespaceResponse' {} Maybe Text
a -> UpdateHttpNamespaceResponse
s {$sel:operationId:UpdateHttpNamespaceResponse' :: Maybe Text
operationId = Maybe Text
a} :: UpdateHttpNamespaceResponse)

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

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