{-# 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.ResourceExplorer2.GetView
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves details of the specified view.
module Amazonka.ResourceExplorer2.GetView
  ( -- * Creating a Request
    GetView (..),
    newGetView,

    -- * Request Lenses
    getView_viewArn,

    -- * Destructuring the Response
    GetViewResponse (..),
    newGetViewResponse,

    -- * Response Lenses
    getViewResponse_tags,
    getViewResponse_view,
    getViewResponse_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 Amazonka.ResourceExplorer2.Types
import qualified Amazonka.Response as Response

-- | /See:/ 'newGetView' smart constructor.
data GetView = GetView'
  { -- | The
    -- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
    -- of the view that you want information about.
    GetView -> Text
viewArn :: Prelude.Text
  }
  deriving (GetView -> GetView -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetView -> GetView -> Bool
$c/= :: GetView -> GetView -> Bool
== :: GetView -> GetView -> Bool
$c== :: GetView -> GetView -> Bool
Prelude.Eq, ReadPrec [GetView]
ReadPrec GetView
Int -> ReadS GetView
ReadS [GetView]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetView]
$creadListPrec :: ReadPrec [GetView]
readPrec :: ReadPrec GetView
$creadPrec :: ReadPrec GetView
readList :: ReadS [GetView]
$creadList :: ReadS [GetView]
readsPrec :: Int -> ReadS GetView
$creadsPrec :: Int -> ReadS GetView
Prelude.Read, Int -> GetView -> ShowS
[GetView] -> ShowS
GetView -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetView] -> ShowS
$cshowList :: [GetView] -> ShowS
show :: GetView -> String
$cshow :: GetView -> String
showsPrec :: Int -> GetView -> ShowS
$cshowsPrec :: Int -> GetView -> ShowS
Prelude.Show, forall x. Rep GetView x -> GetView
forall x. GetView -> Rep GetView x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetView x -> GetView
$cfrom :: forall x. GetView -> Rep GetView x
Prelude.Generic)

-- |
-- Create a value of 'GetView' 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:
--
-- 'viewArn', 'getView_viewArn' - The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
-- of the view that you want information about.
newGetView ::
  -- | 'viewArn'
  Prelude.Text ->
  GetView
newGetView :: Text -> GetView
newGetView Text
pViewArn_ = GetView' {$sel:viewArn:GetView' :: Text
viewArn = Text
pViewArn_}

-- | The
-- <https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html Amazon resource name (ARN)>
-- of the view that you want information about.
getView_viewArn :: Lens.Lens' GetView Prelude.Text
getView_viewArn :: Lens' GetView Text
getView_viewArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetView' {Text
viewArn :: Text
$sel:viewArn:GetView' :: GetView -> Text
viewArn} -> Text
viewArn) (\s :: GetView
s@GetView' {} Text
a -> GetView
s {$sel:viewArn:GetView' :: Text
viewArn = Text
a} :: GetView)

instance Core.AWSRequest GetView where
  type AWSResponse GetView = GetViewResponse
  request :: (Service -> Service) -> GetView -> Request GetView
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 GetView
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetView)))
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 (HashMap Text Text) -> Maybe View -> Int -> GetViewResponse
GetViewResponse'
            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
"Tags" forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty)
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"View")
            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 GetView where
  hashWithSalt :: Int -> GetView -> Int
hashWithSalt Int
_salt GetView' {Text
viewArn :: Text
$sel:viewArn:GetView' :: GetView -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
viewArn

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

instance Data.ToHeaders GetView where
  toHeaders :: GetView -> 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.ToJSON GetView where
  toJSON :: GetView -> Value
toJSON GetView' {Text
viewArn :: Text
$sel:viewArn:GetView' :: GetView -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ViewArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
viewArn)]
      )

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

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

-- | /See:/ 'newGetViewResponse' smart constructor.
data GetViewResponse = GetViewResponse'
  { -- | Tag key and value pairs that are attached to the view.
    GetViewResponse -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | A structure that contains the details for the requested view.
    GetViewResponse -> Maybe View
view :: Prelude.Maybe View,
    -- | The response's http status code.
    GetViewResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetViewResponse -> GetViewResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetViewResponse -> GetViewResponse -> Bool
$c/= :: GetViewResponse -> GetViewResponse -> Bool
== :: GetViewResponse -> GetViewResponse -> Bool
$c== :: GetViewResponse -> GetViewResponse -> Bool
Prelude.Eq, Int -> GetViewResponse -> ShowS
[GetViewResponse] -> ShowS
GetViewResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetViewResponse] -> ShowS
$cshowList :: [GetViewResponse] -> ShowS
show :: GetViewResponse -> String
$cshow :: GetViewResponse -> String
showsPrec :: Int -> GetViewResponse -> ShowS
$cshowsPrec :: Int -> GetViewResponse -> ShowS
Prelude.Show, forall x. Rep GetViewResponse x -> GetViewResponse
forall x. GetViewResponse -> Rep GetViewResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetViewResponse x -> GetViewResponse
$cfrom :: forall x. GetViewResponse -> Rep GetViewResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetViewResponse' 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:
--
-- 'tags', 'getViewResponse_tags' - Tag key and value pairs that are attached to the view.
--
-- 'view', 'getViewResponse_view' - A structure that contains the details for the requested view.
--
-- 'httpStatus', 'getViewResponse_httpStatus' - The response's http status code.
newGetViewResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetViewResponse
newGetViewResponse :: Int -> GetViewResponse
newGetViewResponse Int
pHttpStatus_ =
  GetViewResponse'
    { $sel:tags:GetViewResponse' :: Maybe (HashMap Text Text)
tags = forall a. Maybe a
Prelude.Nothing,
      $sel:view:GetViewResponse' :: Maybe View
view = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetViewResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Tag key and value pairs that are attached to the view.
getViewResponse_tags :: Lens.Lens' GetViewResponse (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
getViewResponse_tags :: Lens' GetViewResponse (Maybe (HashMap Text Text))
getViewResponse_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetViewResponse' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:GetViewResponse' :: GetViewResponse -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: GetViewResponse
s@GetViewResponse' {} Maybe (HashMap Text Text)
a -> GetViewResponse
s {$sel:tags:GetViewResponse' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: GetViewResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A structure that contains the details for the requested view.
getViewResponse_view :: Lens.Lens' GetViewResponse (Prelude.Maybe View)
getViewResponse_view :: Lens' GetViewResponse (Maybe View)
getViewResponse_view = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetViewResponse' {Maybe View
view :: Maybe View
$sel:view:GetViewResponse' :: GetViewResponse -> Maybe View
view} -> Maybe View
view) (\s :: GetViewResponse
s@GetViewResponse' {} Maybe View
a -> GetViewResponse
s {$sel:view:GetViewResponse' :: Maybe View
view = Maybe View
a} :: GetViewResponse)

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

instance Prelude.NFData GetViewResponse where
  rnf :: GetViewResponse -> ()
rnf GetViewResponse' {Int
Maybe (HashMap Text Text)
Maybe View
httpStatus :: Int
view :: Maybe View
tags :: Maybe (HashMap Text Text)
$sel:httpStatus:GetViewResponse' :: GetViewResponse -> Int
$sel:view:GetViewResponse' :: GetViewResponse -> Maybe View
$sel:tags:GetViewResponse' :: GetViewResponse -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
tags
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe View
view
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus