{-# 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.GetNamespace
-- 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)
--
-- Gets information about a namespace.
module Amazonka.Route53AutoNaming.GetNamespace
  ( -- * Creating a Request
    GetNamespace (..),
    newGetNamespace,

    -- * Request Lenses
    getNamespace_id,

    -- * Destructuring the Response
    GetNamespaceResponse (..),
    newGetNamespaceResponse,

    -- * Response Lenses
    getNamespaceResponse_namespace,
    getNamespaceResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetNamespace' smart constructor.
data GetNamespace = GetNamespace'
  { -- | The ID of the namespace that you want to get information about.
    GetNamespace -> Text
id :: Prelude.Text
  }
  deriving (GetNamespace -> GetNamespace -> Bool
(GetNamespace -> GetNamespace -> Bool)
-> (GetNamespace -> GetNamespace -> Bool) -> Eq GetNamespace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNamespace -> GetNamespace -> Bool
$c/= :: GetNamespace -> GetNamespace -> Bool
== :: GetNamespace -> GetNamespace -> Bool
$c== :: GetNamespace -> GetNamespace -> Bool
Prelude.Eq, ReadPrec [GetNamespace]
ReadPrec GetNamespace
Int -> ReadS GetNamespace
ReadS [GetNamespace]
(Int -> ReadS GetNamespace)
-> ReadS [GetNamespace]
-> ReadPrec GetNamespace
-> ReadPrec [GetNamespace]
-> Read GetNamespace
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNamespace]
$creadListPrec :: ReadPrec [GetNamespace]
readPrec :: ReadPrec GetNamespace
$creadPrec :: ReadPrec GetNamespace
readList :: ReadS [GetNamespace]
$creadList :: ReadS [GetNamespace]
readsPrec :: Int -> ReadS GetNamespace
$creadsPrec :: Int -> ReadS GetNamespace
Prelude.Read, Int -> GetNamespace -> ShowS
[GetNamespace] -> ShowS
GetNamespace -> String
(Int -> GetNamespace -> ShowS)
-> (GetNamespace -> String)
-> ([GetNamespace] -> ShowS)
-> Show GetNamespace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNamespace] -> ShowS
$cshowList :: [GetNamespace] -> ShowS
show :: GetNamespace -> String
$cshow :: GetNamespace -> String
showsPrec :: Int -> GetNamespace -> ShowS
$cshowsPrec :: Int -> GetNamespace -> ShowS
Prelude.Show, (forall x. GetNamespace -> Rep GetNamespace x)
-> (forall x. Rep GetNamespace x -> GetNamespace)
-> Generic GetNamespace
forall x. Rep GetNamespace x -> GetNamespace
forall x. GetNamespace -> Rep GetNamespace x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNamespace x -> GetNamespace
$cfrom :: forall x. GetNamespace -> Rep GetNamespace x
Prelude.Generic)

-- |
-- Create a value of 'GetNamespace' 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:
--
-- 'id', 'getNamespace_id' - The ID of the namespace that you want to get information about.
newGetNamespace ::
  -- | 'id'
  Prelude.Text ->
  GetNamespace
newGetNamespace :: Text -> GetNamespace
newGetNamespace Text
pId_ = GetNamespace' :: Text -> GetNamespace
GetNamespace' {$sel:id:GetNamespace' :: Text
id = Text
pId_}

-- | The ID of the namespace that you want to get information about.
getNamespace_id :: Lens.Lens' GetNamespace Prelude.Text
getNamespace_id :: (Text -> f Text) -> GetNamespace -> f GetNamespace
getNamespace_id = (GetNamespace -> Text)
-> (GetNamespace -> Text -> GetNamespace)
-> Lens GetNamespace GetNamespace Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNamespace' {Text
id :: Text
$sel:id:GetNamespace' :: GetNamespace -> Text
id} -> Text
id) (\s :: GetNamespace
s@GetNamespace' {} Text
a -> GetNamespace
s {$sel:id:GetNamespace' :: Text
id = Text
a} :: GetNamespace)

instance Core.AWSRequest GetNamespace where
  type AWSResponse GetNamespace = GetNamespaceResponse
  request :: GetNamespace -> Request GetNamespace
request = Service -> GetNamespace -> Request GetNamespace
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetNamespace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNamespace)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetNamespace))
-> Logger
-> Service
-> Proxy GetNamespace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetNamespace)))
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 Namespace -> Int -> GetNamespaceResponse
GetNamespaceResponse'
            (Maybe Namespace -> Int -> GetNamespaceResponse)
-> Either String (Maybe Namespace)
-> Either String (Int -> GetNamespaceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Namespace)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Namespace")
            Either String (Int -> GetNamespaceResponse)
-> Either String Int -> Either String GetNamespaceResponse
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 GetNamespace

instance Prelude.NFData GetNamespace

instance Core.ToHeaders GetNamespace where
  toHeaders :: GetNamespace -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetNamespace -> 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
"Route53AutoNaming_v20170314.GetNamespace" ::
                          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 GetNamespace where
  toJSON :: GetNamespace -> Value
toJSON GetNamespace' {Text
id :: Text
$sel:id:GetNamespace' :: GetNamespace -> Text
..} =
    [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
"Id" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
id)])

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

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

-- | /See:/ 'newGetNamespaceResponse' smart constructor.
data GetNamespaceResponse = GetNamespaceResponse'
  { -- | A complex type that contains information about the specified namespace.
    GetNamespaceResponse -> Maybe Namespace
namespace :: Prelude.Maybe Namespace,
    -- | The response's http status code.
    GetNamespaceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetNamespaceResponse -> GetNamespaceResponse -> Bool
(GetNamespaceResponse -> GetNamespaceResponse -> Bool)
-> (GetNamespaceResponse -> GetNamespaceResponse -> Bool)
-> Eq GetNamespaceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetNamespaceResponse -> GetNamespaceResponse -> Bool
$c/= :: GetNamespaceResponse -> GetNamespaceResponse -> Bool
== :: GetNamespaceResponse -> GetNamespaceResponse -> Bool
$c== :: GetNamespaceResponse -> GetNamespaceResponse -> Bool
Prelude.Eq, ReadPrec [GetNamespaceResponse]
ReadPrec GetNamespaceResponse
Int -> ReadS GetNamespaceResponse
ReadS [GetNamespaceResponse]
(Int -> ReadS GetNamespaceResponse)
-> ReadS [GetNamespaceResponse]
-> ReadPrec GetNamespaceResponse
-> ReadPrec [GetNamespaceResponse]
-> Read GetNamespaceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetNamespaceResponse]
$creadListPrec :: ReadPrec [GetNamespaceResponse]
readPrec :: ReadPrec GetNamespaceResponse
$creadPrec :: ReadPrec GetNamespaceResponse
readList :: ReadS [GetNamespaceResponse]
$creadList :: ReadS [GetNamespaceResponse]
readsPrec :: Int -> ReadS GetNamespaceResponse
$creadsPrec :: Int -> ReadS GetNamespaceResponse
Prelude.Read, Int -> GetNamespaceResponse -> ShowS
[GetNamespaceResponse] -> ShowS
GetNamespaceResponse -> String
(Int -> GetNamespaceResponse -> ShowS)
-> (GetNamespaceResponse -> String)
-> ([GetNamespaceResponse] -> ShowS)
-> Show GetNamespaceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetNamespaceResponse] -> ShowS
$cshowList :: [GetNamespaceResponse] -> ShowS
show :: GetNamespaceResponse -> String
$cshow :: GetNamespaceResponse -> String
showsPrec :: Int -> GetNamespaceResponse -> ShowS
$cshowsPrec :: Int -> GetNamespaceResponse -> ShowS
Prelude.Show, (forall x. GetNamespaceResponse -> Rep GetNamespaceResponse x)
-> (forall x. Rep GetNamespaceResponse x -> GetNamespaceResponse)
-> Generic GetNamespaceResponse
forall x. Rep GetNamespaceResponse x -> GetNamespaceResponse
forall x. GetNamespaceResponse -> Rep GetNamespaceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetNamespaceResponse x -> GetNamespaceResponse
$cfrom :: forall x. GetNamespaceResponse -> Rep GetNamespaceResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetNamespaceResponse' 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:
--
-- 'namespace', 'getNamespaceResponse_namespace' - A complex type that contains information about the specified namespace.
--
-- 'httpStatus', 'getNamespaceResponse_httpStatus' - The response's http status code.
newGetNamespaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetNamespaceResponse
newGetNamespaceResponse :: Int -> GetNamespaceResponse
newGetNamespaceResponse Int
pHttpStatus_ =
  GetNamespaceResponse' :: Maybe Namespace -> Int -> GetNamespaceResponse
GetNamespaceResponse'
    { $sel:namespace:GetNamespaceResponse' :: Maybe Namespace
namespace = Maybe Namespace
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetNamespaceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A complex type that contains information about the specified namespace.
getNamespaceResponse_namespace :: Lens.Lens' GetNamespaceResponse (Prelude.Maybe Namespace)
getNamespaceResponse_namespace :: (Maybe Namespace -> f (Maybe Namespace))
-> GetNamespaceResponse -> f GetNamespaceResponse
getNamespaceResponse_namespace = (GetNamespaceResponse -> Maybe Namespace)
-> (GetNamespaceResponse
    -> Maybe Namespace -> GetNamespaceResponse)
-> Lens
     GetNamespaceResponse
     GetNamespaceResponse
     (Maybe Namespace)
     (Maybe Namespace)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetNamespaceResponse' {Maybe Namespace
namespace :: Maybe Namespace
$sel:namespace:GetNamespaceResponse' :: GetNamespaceResponse -> Maybe Namespace
namespace} -> Maybe Namespace
namespace) (\s :: GetNamespaceResponse
s@GetNamespaceResponse' {} Maybe Namespace
a -> GetNamespaceResponse
s {$sel:namespace:GetNamespaceResponse' :: Maybe Namespace
namespace = Maybe Namespace
a} :: GetNamespaceResponse)

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

instance Prelude.NFData GetNamespaceResponse