{-# 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.KeySpaces.GetKeyspace
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Returns the name and the Amazon Resource Name (ARN) of the specified
-- table.
module Amazonka.KeySpaces.GetKeyspace
  ( -- * Creating a Request
    GetKeyspace (..),
    newGetKeyspace,

    -- * Request Lenses
    getKeyspace_keyspaceName,

    -- * Destructuring the Response
    GetKeyspaceResponse (..),
    newGetKeyspaceResponse,

    -- * Response Lenses
    getKeyspaceResponse_httpStatus,
    getKeyspaceResponse_keyspaceName,
    getKeyspaceResponse_resourceArn,
  )
where

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

-- | /See:/ 'newGetKeyspace' smart constructor.
data GetKeyspace = GetKeyspace'
  { -- | The name of the keyspace.
    GetKeyspace -> Text
keyspaceName :: Prelude.Text
  }
  deriving (GetKeyspace -> GetKeyspace -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetKeyspace -> GetKeyspace -> Bool
$c/= :: GetKeyspace -> GetKeyspace -> Bool
== :: GetKeyspace -> GetKeyspace -> Bool
$c== :: GetKeyspace -> GetKeyspace -> Bool
Prelude.Eq, ReadPrec [GetKeyspace]
ReadPrec GetKeyspace
Int -> ReadS GetKeyspace
ReadS [GetKeyspace]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetKeyspace]
$creadListPrec :: ReadPrec [GetKeyspace]
readPrec :: ReadPrec GetKeyspace
$creadPrec :: ReadPrec GetKeyspace
readList :: ReadS [GetKeyspace]
$creadList :: ReadS [GetKeyspace]
readsPrec :: Int -> ReadS GetKeyspace
$creadsPrec :: Int -> ReadS GetKeyspace
Prelude.Read, Int -> GetKeyspace -> ShowS
[GetKeyspace] -> ShowS
GetKeyspace -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetKeyspace] -> ShowS
$cshowList :: [GetKeyspace] -> ShowS
show :: GetKeyspace -> String
$cshow :: GetKeyspace -> String
showsPrec :: Int -> GetKeyspace -> ShowS
$cshowsPrec :: Int -> GetKeyspace -> ShowS
Prelude.Show, forall x. Rep GetKeyspace x -> GetKeyspace
forall x. GetKeyspace -> Rep GetKeyspace x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetKeyspace x -> GetKeyspace
$cfrom :: forall x. GetKeyspace -> Rep GetKeyspace x
Prelude.Generic)

-- |
-- Create a value of 'GetKeyspace' 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:
--
-- 'keyspaceName', 'getKeyspace_keyspaceName' - The name of the keyspace.
newGetKeyspace ::
  -- | 'keyspaceName'
  Prelude.Text ->
  GetKeyspace
newGetKeyspace :: Text -> GetKeyspace
newGetKeyspace Text
pKeyspaceName_ =
  GetKeyspace' {$sel:keyspaceName:GetKeyspace' :: Text
keyspaceName = Text
pKeyspaceName_}

-- | The name of the keyspace.
getKeyspace_keyspaceName :: Lens.Lens' GetKeyspace Prelude.Text
getKeyspace_keyspaceName :: Lens' GetKeyspace Text
getKeyspace_keyspaceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyspace' {Text
keyspaceName :: Text
$sel:keyspaceName:GetKeyspace' :: GetKeyspace -> Text
keyspaceName} -> Text
keyspaceName) (\s :: GetKeyspace
s@GetKeyspace' {} Text
a -> GetKeyspace
s {$sel:keyspaceName:GetKeyspace' :: Text
keyspaceName = Text
a} :: GetKeyspace)

instance Core.AWSRequest GetKeyspace where
  type AWSResponse GetKeyspace = GetKeyspaceResponse
  request :: (Service -> Service) -> GetKeyspace -> Request GetKeyspace
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 GetKeyspace
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetKeyspace)))
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 ->
          Int -> Text -> Text -> GetKeyspaceResponse
GetKeyspaceResponse'
            forall (f :: * -> *) a b. Functor 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))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"keyspaceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String a
Data..:> Key
"resourceArn")
      )

instance Prelude.Hashable GetKeyspace where
  hashWithSalt :: Int -> GetKeyspace -> Int
hashWithSalt Int
_salt GetKeyspace' {Text
keyspaceName :: Text
$sel:keyspaceName:GetKeyspace' :: GetKeyspace -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
keyspaceName

instance Prelude.NFData GetKeyspace where
  rnf :: GetKeyspace -> ()
rnf GetKeyspace' {Text
keyspaceName :: Text
$sel:keyspaceName:GetKeyspace' :: GetKeyspace -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
keyspaceName

instance Data.ToHeaders GetKeyspace where
  toHeaders :: GetKeyspace -> 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
"KeyspacesService.GetKeyspace" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.0" ::
                          Prelude.ByteString
                      )
          ]
      )

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

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

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

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

-- |
-- Create a value of 'GetKeyspaceResponse' 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:
--
-- 'httpStatus', 'getKeyspaceResponse_httpStatus' - The response's http status code.
--
-- 'keyspaceName', 'getKeyspaceResponse_keyspaceName' - The name of the keyspace.
--
-- 'resourceArn', 'getKeyspaceResponse_resourceArn' - The ARN of the keyspace.
newGetKeyspaceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'keyspaceName'
  Prelude.Text ->
  -- | 'resourceArn'
  Prelude.Text ->
  GetKeyspaceResponse
newGetKeyspaceResponse :: Int -> Text -> Text -> GetKeyspaceResponse
newGetKeyspaceResponse
  Int
pHttpStatus_
  Text
pKeyspaceName_
  Text
pResourceArn_ =
    GetKeyspaceResponse'
      { $sel:httpStatus:GetKeyspaceResponse' :: Int
httpStatus = Int
pHttpStatus_,
        $sel:keyspaceName:GetKeyspaceResponse' :: Text
keyspaceName = Text
pKeyspaceName_,
        $sel:resourceArn:GetKeyspaceResponse' :: Text
resourceArn = Text
pResourceArn_
      }

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

-- | The name of the keyspace.
getKeyspaceResponse_keyspaceName :: Lens.Lens' GetKeyspaceResponse Prelude.Text
getKeyspaceResponse_keyspaceName :: Lens' GetKeyspaceResponse Text
getKeyspaceResponse_keyspaceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyspaceResponse' {Text
keyspaceName :: Text
$sel:keyspaceName:GetKeyspaceResponse' :: GetKeyspaceResponse -> Text
keyspaceName} -> Text
keyspaceName) (\s :: GetKeyspaceResponse
s@GetKeyspaceResponse' {} Text
a -> GetKeyspaceResponse
s {$sel:keyspaceName:GetKeyspaceResponse' :: Text
keyspaceName = Text
a} :: GetKeyspaceResponse)

-- | The ARN of the keyspace.
getKeyspaceResponse_resourceArn :: Lens.Lens' GetKeyspaceResponse Prelude.Text
getKeyspaceResponse_resourceArn :: Lens' GetKeyspaceResponse Text
getKeyspaceResponse_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetKeyspaceResponse' {Text
resourceArn :: Text
$sel:resourceArn:GetKeyspaceResponse' :: GetKeyspaceResponse -> Text
resourceArn} -> Text
resourceArn) (\s :: GetKeyspaceResponse
s@GetKeyspaceResponse' {} Text
a -> GetKeyspaceResponse
s {$sel:resourceArn:GetKeyspaceResponse' :: Text
resourceArn = Text
a} :: GetKeyspaceResponse)

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