{-# 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.WellArchitected.GetLens
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get an existing lens.
module Amazonka.WellArchitected.GetLens
  ( -- * Creating a Request
    GetLens (..),
    newGetLens,

    -- * Request Lenses
    getLens_lensVersion,
    getLens_lensAlias,

    -- * Destructuring the Response
    GetLensResponse (..),
    newGetLensResponse,

    -- * Response Lenses
    getLensResponse_lens,
    getLensResponse_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.WellArchitected.Types

-- | /See:/ 'newGetLens' smart constructor.
data GetLens = GetLens'
  { -- | The lens version to be retrieved.
    GetLens -> Maybe Text
lensVersion :: Prelude.Maybe Prelude.Text,
    GetLens -> Text
lensAlias :: Prelude.Text
  }
  deriving (GetLens -> GetLens -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLens -> GetLens -> Bool
$c/= :: GetLens -> GetLens -> Bool
== :: GetLens -> GetLens -> Bool
$c== :: GetLens -> GetLens -> Bool
Prelude.Eq, ReadPrec [GetLens]
ReadPrec GetLens
Int -> ReadS GetLens
ReadS [GetLens]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLens]
$creadListPrec :: ReadPrec [GetLens]
readPrec :: ReadPrec GetLens
$creadPrec :: ReadPrec GetLens
readList :: ReadS [GetLens]
$creadList :: ReadS [GetLens]
readsPrec :: Int -> ReadS GetLens
$creadsPrec :: Int -> ReadS GetLens
Prelude.Read, Int -> GetLens -> ShowS
[GetLens] -> ShowS
GetLens -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLens] -> ShowS
$cshowList :: [GetLens] -> ShowS
show :: GetLens -> String
$cshow :: GetLens -> String
showsPrec :: Int -> GetLens -> ShowS
$cshowsPrec :: Int -> GetLens -> ShowS
Prelude.Show, forall x. Rep GetLens x -> GetLens
forall x. GetLens -> Rep GetLens x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLens x -> GetLens
$cfrom :: forall x. GetLens -> Rep GetLens x
Prelude.Generic)

-- |
-- Create a value of 'GetLens' 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:
--
-- 'lensVersion', 'getLens_lensVersion' - The lens version to be retrieved.
--
-- 'lensAlias', 'getLens_lensAlias' - Undocumented member.
newGetLens ::
  -- | 'lensAlias'
  Prelude.Text ->
  GetLens
newGetLens :: Text -> GetLens
newGetLens Text
pLensAlias_ =
  GetLens'
    { $sel:lensVersion:GetLens' :: Maybe Text
lensVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:lensAlias:GetLens' :: Text
lensAlias = Text
pLensAlias_
    }

-- | The lens version to be retrieved.
getLens_lensVersion :: Lens.Lens' GetLens (Prelude.Maybe Prelude.Text)
getLens_lensVersion :: Lens' GetLens (Maybe Text)
getLens_lensVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLens' {Maybe Text
lensVersion :: Maybe Text
$sel:lensVersion:GetLens' :: GetLens -> Maybe Text
lensVersion} -> Maybe Text
lensVersion) (\s :: GetLens
s@GetLens' {} Maybe Text
a -> GetLens
s {$sel:lensVersion:GetLens' :: Maybe Text
lensVersion = Maybe Text
a} :: GetLens)

-- | Undocumented member.
getLens_lensAlias :: Lens.Lens' GetLens Prelude.Text
getLens_lensAlias :: Lens' GetLens Text
getLens_lensAlias = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLens' {Text
lensAlias :: Text
$sel:lensAlias:GetLens' :: GetLens -> Text
lensAlias} -> Text
lensAlias) (\s :: GetLens
s@GetLens' {} Text
a -> GetLens
s {$sel:lensAlias:GetLens' :: Text
lensAlias = Text
a} :: GetLens)

instance Core.AWSRequest GetLens where
  type AWSResponse GetLens = GetLensResponse
  request :: (Service -> Service) -> GetLens -> Request GetLens
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetLens
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetLens)))
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 Lens -> Int -> GetLensResponse
GetLensResponse'
            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
"Lens")
            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 GetLens where
  hashWithSalt :: Int -> GetLens -> Int
hashWithSalt Int
_salt GetLens' {Maybe Text
Text
lensAlias :: Text
lensVersion :: Maybe Text
$sel:lensAlias:GetLens' :: GetLens -> Text
$sel:lensVersion:GetLens' :: GetLens -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
lensVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
lensAlias

instance Prelude.NFData GetLens where
  rnf :: GetLens -> ()
rnf GetLens' {Maybe Text
Text
lensAlias :: Text
lensVersion :: Maybe Text
$sel:lensAlias:GetLens' :: GetLens -> Text
$sel:lensVersion:GetLens' :: GetLens -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
lensVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
lensAlias

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

instance Data.ToPath GetLens where
  toPath :: GetLens -> ByteString
toPath GetLens' {Maybe Text
Text
lensAlias :: Text
lensVersion :: Maybe Text
$sel:lensAlias:GetLens' :: GetLens -> Text
$sel:lensVersion:GetLens' :: GetLens -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/lenses/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
lensAlias]

instance Data.ToQuery GetLens where
  toQuery :: GetLens -> QueryString
toQuery GetLens' {Maybe Text
Text
lensAlias :: Text
lensVersion :: Maybe Text
$sel:lensAlias:GetLens' :: GetLens -> Text
$sel:lensVersion:GetLens' :: GetLens -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"LensVersion" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
lensVersion]

-- | /See:/ 'newGetLensResponse' smart constructor.
data GetLensResponse = GetLensResponse'
  { -- | A lens return object.
    GetLensResponse -> Maybe Lens
lens :: Prelude.Maybe Lens,
    -- | The response's http status code.
    GetLensResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetLensResponse -> GetLensResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetLensResponse -> GetLensResponse -> Bool
$c/= :: GetLensResponse -> GetLensResponse -> Bool
== :: GetLensResponse -> GetLensResponse -> Bool
$c== :: GetLensResponse -> GetLensResponse -> Bool
Prelude.Eq, ReadPrec [GetLensResponse]
ReadPrec GetLensResponse
Int -> ReadS GetLensResponse
ReadS [GetLensResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetLensResponse]
$creadListPrec :: ReadPrec [GetLensResponse]
readPrec :: ReadPrec GetLensResponse
$creadPrec :: ReadPrec GetLensResponse
readList :: ReadS [GetLensResponse]
$creadList :: ReadS [GetLensResponse]
readsPrec :: Int -> ReadS GetLensResponse
$creadsPrec :: Int -> ReadS GetLensResponse
Prelude.Read, Int -> GetLensResponse -> ShowS
[GetLensResponse] -> ShowS
GetLensResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetLensResponse] -> ShowS
$cshowList :: [GetLensResponse] -> ShowS
show :: GetLensResponse -> String
$cshow :: GetLensResponse -> String
showsPrec :: Int -> GetLensResponse -> ShowS
$cshowsPrec :: Int -> GetLensResponse -> ShowS
Prelude.Show, forall x. Rep GetLensResponse x -> GetLensResponse
forall x. GetLensResponse -> Rep GetLensResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetLensResponse x -> GetLensResponse
$cfrom :: forall x. GetLensResponse -> Rep GetLensResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetLensResponse' 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:
--
-- 'lens', 'getLensResponse_lens' - A lens return object.
--
-- 'httpStatus', 'getLensResponse_httpStatus' - The response's http status code.
newGetLensResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetLensResponse
newGetLensResponse :: Int -> GetLensResponse
newGetLensResponse Int
pHttpStatus_ =
  GetLensResponse'
    { $sel:lens:GetLensResponse' :: Maybe Lens
lens = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetLensResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A lens return object.
getLensResponse_lens :: Lens.Lens' GetLensResponse (Prelude.Maybe Lens)
getLensResponse_lens :: Lens' GetLensResponse (Maybe Lens)
getLensResponse_lens = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetLensResponse' {Maybe Lens
lens :: Maybe Lens
$sel:lens:GetLensResponse' :: GetLensResponse -> Maybe Lens
lens} -> Maybe Lens
lens) (\s :: GetLensResponse
s@GetLensResponse' {} Maybe Lens
a -> GetLensResponse
s {$sel:lens:GetLensResponse' :: Maybe Lens
lens = Maybe Lens
a} :: GetLensResponse)

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

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