{-# 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.QuickSight.DescribeNamespace
-- 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)
--
-- Describes the current namespace.
module Amazonka.QuickSight.DescribeNamespace
  ( -- * Creating a Request
    DescribeNamespace (..),
    newDescribeNamespace,

    -- * Request Lenses
    describeNamespace_awsAccountId,
    describeNamespace_namespace,

    -- * Destructuring the Response
    DescribeNamespaceResponse (..),
    newDescribeNamespaceResponse,

    -- * Response Lenses
    describeNamespaceResponse_requestId,
    describeNamespaceResponse_namespace,
    describeNamespaceResponse_status,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeNamespace' smart constructor.
data DescribeNamespace = DescribeNamespace'
  { -- | The ID for the Amazon Web Services account that contains the Amazon
    -- QuickSight namespace that you want to describe.
    DescribeNamespace -> Text
awsAccountId :: Prelude.Text,
    -- | The namespace that you want to describe.
    DescribeNamespace -> Text
namespace :: Prelude.Text
  }
  deriving (DescribeNamespace -> DescribeNamespace -> Bool
(DescribeNamespace -> DescribeNamespace -> Bool)
-> (DescribeNamespace -> DescribeNamespace -> Bool)
-> Eq DescribeNamespace
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeNamespace -> DescribeNamespace -> Bool
$c/= :: DescribeNamespace -> DescribeNamespace -> Bool
== :: DescribeNamespace -> DescribeNamespace -> Bool
$c== :: DescribeNamespace -> DescribeNamespace -> Bool
Prelude.Eq, ReadPrec [DescribeNamespace]
ReadPrec DescribeNamespace
Int -> ReadS DescribeNamespace
ReadS [DescribeNamespace]
(Int -> ReadS DescribeNamespace)
-> ReadS [DescribeNamespace]
-> ReadPrec DescribeNamespace
-> ReadPrec [DescribeNamespace]
-> Read DescribeNamespace
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeNamespace]
$creadListPrec :: ReadPrec [DescribeNamespace]
readPrec :: ReadPrec DescribeNamespace
$creadPrec :: ReadPrec DescribeNamespace
readList :: ReadS [DescribeNamespace]
$creadList :: ReadS [DescribeNamespace]
readsPrec :: Int -> ReadS DescribeNamespace
$creadsPrec :: Int -> ReadS DescribeNamespace
Prelude.Read, Int -> DescribeNamespace -> ShowS
[DescribeNamespace] -> ShowS
DescribeNamespace -> String
(Int -> DescribeNamespace -> ShowS)
-> (DescribeNamespace -> String)
-> ([DescribeNamespace] -> ShowS)
-> Show DescribeNamespace
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeNamespace] -> ShowS
$cshowList :: [DescribeNamespace] -> ShowS
show :: DescribeNamespace -> String
$cshow :: DescribeNamespace -> String
showsPrec :: Int -> DescribeNamespace -> ShowS
$cshowsPrec :: Int -> DescribeNamespace -> ShowS
Prelude.Show, (forall x. DescribeNamespace -> Rep DescribeNamespace x)
-> (forall x. Rep DescribeNamespace x -> DescribeNamespace)
-> Generic DescribeNamespace
forall x. Rep DescribeNamespace x -> DescribeNamespace
forall x. DescribeNamespace -> Rep DescribeNamespace x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeNamespace x -> DescribeNamespace
$cfrom :: forall x. DescribeNamespace -> Rep DescribeNamespace x
Prelude.Generic)

-- |
-- Create a value of 'DescribeNamespace' 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:
--
-- 'awsAccountId', 'describeNamespace_awsAccountId' - The ID for the Amazon Web Services account that contains the Amazon
-- QuickSight namespace that you want to describe.
--
-- 'namespace', 'describeNamespace_namespace' - The namespace that you want to describe.
newDescribeNamespace ::
  -- | 'awsAccountId'
  Prelude.Text ->
  -- | 'namespace'
  Prelude.Text ->
  DescribeNamespace
newDescribeNamespace :: Text -> Text -> DescribeNamespace
newDescribeNamespace Text
pAwsAccountId_ Text
pNamespace_ =
  DescribeNamespace' :: Text -> Text -> DescribeNamespace
DescribeNamespace'
    { $sel:awsAccountId:DescribeNamespace' :: Text
awsAccountId = Text
pAwsAccountId_,
      $sel:namespace:DescribeNamespace' :: Text
namespace = Text
pNamespace_
    }

-- | The ID for the Amazon Web Services account that contains the Amazon
-- QuickSight namespace that you want to describe.
describeNamespace_awsAccountId :: Lens.Lens' DescribeNamespace Prelude.Text
describeNamespace_awsAccountId :: (Text -> f Text) -> DescribeNamespace -> f DescribeNamespace
describeNamespace_awsAccountId = (DescribeNamespace -> Text)
-> (DescribeNamespace -> Text -> DescribeNamespace)
-> Lens DescribeNamespace DescribeNamespace Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeNamespace' {Text
awsAccountId :: Text
$sel:awsAccountId:DescribeNamespace' :: DescribeNamespace -> Text
awsAccountId} -> Text
awsAccountId) (\s :: DescribeNamespace
s@DescribeNamespace' {} Text
a -> DescribeNamespace
s {$sel:awsAccountId:DescribeNamespace' :: Text
awsAccountId = Text
a} :: DescribeNamespace)

-- | The namespace that you want to describe.
describeNamespace_namespace :: Lens.Lens' DescribeNamespace Prelude.Text
describeNamespace_namespace :: (Text -> f Text) -> DescribeNamespace -> f DescribeNamespace
describeNamespace_namespace = (DescribeNamespace -> Text)
-> (DescribeNamespace -> Text -> DescribeNamespace)
-> Lens DescribeNamespace DescribeNamespace Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeNamespace' {Text
namespace :: Text
$sel:namespace:DescribeNamespace' :: DescribeNamespace -> Text
namespace} -> Text
namespace) (\s :: DescribeNamespace
s@DescribeNamespace' {} Text
a -> DescribeNamespace
s {$sel:namespace:DescribeNamespace' :: Text
namespace = Text
a} :: DescribeNamespace)

instance Core.AWSRequest DescribeNamespace where
  type
    AWSResponse DescribeNamespace =
      DescribeNamespaceResponse
  request :: DescribeNamespace -> Request DescribeNamespace
request = Service -> DescribeNamespace -> Request DescribeNamespace
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeNamespace
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeNamespace)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeNamespace))
-> Logger
-> Service
-> Proxy DescribeNamespace
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeNamespace)))
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 NamespaceInfoV2 -> Int -> DescribeNamespaceResponse
DescribeNamespaceResponse'
            (Maybe Text
 -> Maybe NamespaceInfoV2 -> Int -> DescribeNamespaceResponse)
-> Either String (Maybe Text)
-> Either
     String (Maybe NamespaceInfoV2 -> Int -> DescribeNamespaceResponse)
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
"RequestId")
            Either
  String (Maybe NamespaceInfoV2 -> Int -> DescribeNamespaceResponse)
-> Either String (Maybe NamespaceInfoV2)
-> Either String (Int -> DescribeNamespaceResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe NamespaceInfoV2)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Namespace")
            Either String (Int -> DescribeNamespaceResponse)
-> Either String Int -> Either String DescribeNamespaceResponse
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 DescribeNamespace

instance Prelude.NFData DescribeNamespace

instance Core.ToHeaders DescribeNamespace where
  toHeaders :: DescribeNamespace -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeNamespace -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DescribeNamespace where
  toPath :: DescribeNamespace -> ByteString
toPath DescribeNamespace' {Text
namespace :: Text
awsAccountId :: Text
$sel:namespace:DescribeNamespace' :: DescribeNamespace -> Text
$sel:awsAccountId:DescribeNamespace' :: DescribeNamespace -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/accounts/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
awsAccountId,
        ByteString
"/namespaces/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
namespace
      ]

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

-- | /See:/ 'newDescribeNamespaceResponse' smart constructor.
data DescribeNamespaceResponse = DescribeNamespaceResponse'
  { -- | The Amazon Web Services request ID for this operation.
    DescribeNamespaceResponse -> Maybe Text
requestId :: Prelude.Maybe Prelude.Text,
    -- | The information about the namespace that you\'re describing. The
    -- response includes the namespace ARN, name, Amazon Web Services Region,
    -- creation status, and identity store. @DescribeNamespace@ also works for
    -- namespaces that are in the process of being created. For incomplete
    -- namespaces, this API operation lists the namespace error types and
    -- messages associated with the creation process.
    DescribeNamespaceResponse -> Maybe NamespaceInfoV2
namespace :: Prelude.Maybe NamespaceInfoV2,
    -- | The HTTP status of the request.
    DescribeNamespaceResponse -> Int
status :: Prelude.Int
  }
  deriving (DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool
(DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool)
-> (DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool)
-> Eq DescribeNamespaceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool
$c/= :: DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool
== :: DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool
$c== :: DescribeNamespaceResponse -> DescribeNamespaceResponse -> Bool
Prelude.Eq, ReadPrec [DescribeNamespaceResponse]
ReadPrec DescribeNamespaceResponse
Int -> ReadS DescribeNamespaceResponse
ReadS [DescribeNamespaceResponse]
(Int -> ReadS DescribeNamespaceResponse)
-> ReadS [DescribeNamespaceResponse]
-> ReadPrec DescribeNamespaceResponse
-> ReadPrec [DescribeNamespaceResponse]
-> Read DescribeNamespaceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeNamespaceResponse]
$creadListPrec :: ReadPrec [DescribeNamespaceResponse]
readPrec :: ReadPrec DescribeNamespaceResponse
$creadPrec :: ReadPrec DescribeNamespaceResponse
readList :: ReadS [DescribeNamespaceResponse]
$creadList :: ReadS [DescribeNamespaceResponse]
readsPrec :: Int -> ReadS DescribeNamespaceResponse
$creadsPrec :: Int -> ReadS DescribeNamespaceResponse
Prelude.Read, Int -> DescribeNamespaceResponse -> ShowS
[DescribeNamespaceResponse] -> ShowS
DescribeNamespaceResponse -> String
(Int -> DescribeNamespaceResponse -> ShowS)
-> (DescribeNamespaceResponse -> String)
-> ([DescribeNamespaceResponse] -> ShowS)
-> Show DescribeNamespaceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeNamespaceResponse] -> ShowS
$cshowList :: [DescribeNamespaceResponse] -> ShowS
show :: DescribeNamespaceResponse -> String
$cshow :: DescribeNamespaceResponse -> String
showsPrec :: Int -> DescribeNamespaceResponse -> ShowS
$cshowsPrec :: Int -> DescribeNamespaceResponse -> ShowS
Prelude.Show, (forall x.
 DescribeNamespaceResponse -> Rep DescribeNamespaceResponse x)
-> (forall x.
    Rep DescribeNamespaceResponse x -> DescribeNamespaceResponse)
-> Generic DescribeNamespaceResponse
forall x.
Rep DescribeNamespaceResponse x -> DescribeNamespaceResponse
forall x.
DescribeNamespaceResponse -> Rep DescribeNamespaceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeNamespaceResponse x -> DescribeNamespaceResponse
$cfrom :: forall x.
DescribeNamespaceResponse -> Rep DescribeNamespaceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeNamespaceResponse' 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:
--
-- 'requestId', 'describeNamespaceResponse_requestId' - The Amazon Web Services request ID for this operation.
--
-- 'namespace', 'describeNamespaceResponse_namespace' - The information about the namespace that you\'re describing. The
-- response includes the namespace ARN, name, Amazon Web Services Region,
-- creation status, and identity store. @DescribeNamespace@ also works for
-- namespaces that are in the process of being created. For incomplete
-- namespaces, this API operation lists the namespace error types and
-- messages associated with the creation process.
--
-- 'status', 'describeNamespaceResponse_status' - The HTTP status of the request.
newDescribeNamespaceResponse ::
  -- | 'status'
  Prelude.Int ->
  DescribeNamespaceResponse
newDescribeNamespaceResponse :: Int -> DescribeNamespaceResponse
newDescribeNamespaceResponse Int
pStatus_ =
  DescribeNamespaceResponse' :: Maybe Text
-> Maybe NamespaceInfoV2 -> Int -> DescribeNamespaceResponse
DescribeNamespaceResponse'
    { $sel:requestId:DescribeNamespaceResponse' :: Maybe Text
requestId =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:namespace:DescribeNamespaceResponse' :: Maybe NamespaceInfoV2
namespace = Maybe NamespaceInfoV2
forall a. Maybe a
Prelude.Nothing,
      $sel:status:DescribeNamespaceResponse' :: Int
status = Int
pStatus_
    }

-- | The Amazon Web Services request ID for this operation.
describeNamespaceResponse_requestId :: Lens.Lens' DescribeNamespaceResponse (Prelude.Maybe Prelude.Text)
describeNamespaceResponse_requestId :: (Maybe Text -> f (Maybe Text))
-> DescribeNamespaceResponse -> f DescribeNamespaceResponse
describeNamespaceResponse_requestId = (DescribeNamespaceResponse -> Maybe Text)
-> (DescribeNamespaceResponse
    -> Maybe Text -> DescribeNamespaceResponse)
-> Lens
     DescribeNamespaceResponse
     DescribeNamespaceResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeNamespaceResponse' {Maybe Text
requestId :: Maybe Text
$sel:requestId:DescribeNamespaceResponse' :: DescribeNamespaceResponse -> Maybe Text
requestId} -> Maybe Text
requestId) (\s :: DescribeNamespaceResponse
s@DescribeNamespaceResponse' {} Maybe Text
a -> DescribeNamespaceResponse
s {$sel:requestId:DescribeNamespaceResponse' :: Maybe Text
requestId = Maybe Text
a} :: DescribeNamespaceResponse)

-- | The information about the namespace that you\'re describing. The
-- response includes the namespace ARN, name, Amazon Web Services Region,
-- creation status, and identity store. @DescribeNamespace@ also works for
-- namespaces that are in the process of being created. For incomplete
-- namespaces, this API operation lists the namespace error types and
-- messages associated with the creation process.
describeNamespaceResponse_namespace :: Lens.Lens' DescribeNamespaceResponse (Prelude.Maybe NamespaceInfoV2)
describeNamespaceResponse_namespace :: (Maybe NamespaceInfoV2 -> f (Maybe NamespaceInfoV2))
-> DescribeNamespaceResponse -> f DescribeNamespaceResponse
describeNamespaceResponse_namespace = (DescribeNamespaceResponse -> Maybe NamespaceInfoV2)
-> (DescribeNamespaceResponse
    -> Maybe NamespaceInfoV2 -> DescribeNamespaceResponse)
-> Lens
     DescribeNamespaceResponse
     DescribeNamespaceResponse
     (Maybe NamespaceInfoV2)
     (Maybe NamespaceInfoV2)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeNamespaceResponse' {Maybe NamespaceInfoV2
namespace :: Maybe NamespaceInfoV2
$sel:namespace:DescribeNamespaceResponse' :: DescribeNamespaceResponse -> Maybe NamespaceInfoV2
namespace} -> Maybe NamespaceInfoV2
namespace) (\s :: DescribeNamespaceResponse
s@DescribeNamespaceResponse' {} Maybe NamespaceInfoV2
a -> DescribeNamespaceResponse
s {$sel:namespace:DescribeNamespaceResponse' :: Maybe NamespaceInfoV2
namespace = Maybe NamespaceInfoV2
a} :: DescribeNamespaceResponse)

-- | The HTTP status of the request.
describeNamespaceResponse_status :: Lens.Lens' DescribeNamespaceResponse Prelude.Int
describeNamespaceResponse_status :: (Int -> f Int)
-> DescribeNamespaceResponse -> f DescribeNamespaceResponse
describeNamespaceResponse_status = (DescribeNamespaceResponse -> Int)
-> (DescribeNamespaceResponse -> Int -> DescribeNamespaceResponse)
-> Lens DescribeNamespaceResponse DescribeNamespaceResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeNamespaceResponse' {Int
status :: Int
$sel:status:DescribeNamespaceResponse' :: DescribeNamespaceResponse -> Int
status} -> Int
status) (\s :: DescribeNamespaceResponse
s@DescribeNamespaceResponse' {} Int
a -> DescribeNamespaceResponse
s {$sel:status:DescribeNamespaceResponse' :: Int
status = Int
a} :: DescribeNamespaceResponse)

instance Prelude.NFData DescribeNamespaceResponse