{-# 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.ServiceCatalog.DescribeProductView
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets information about the specified product.
module Amazonka.ServiceCatalog.DescribeProductView
  ( -- * Creating a Request
    DescribeProductView (..),
    newDescribeProductView,

    -- * Request Lenses
    describeProductView_acceptLanguage,
    describeProductView_id,

    -- * Destructuring the Response
    DescribeProductViewResponse (..),
    newDescribeProductViewResponse,

    -- * Response Lenses
    describeProductViewResponse_productViewSummary,
    describeProductViewResponse_provisioningArtifacts,
    describeProductViewResponse_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.ServiceCatalog.Types

-- | /See:/ 'newDescribeProductView' smart constructor.
data DescribeProductView = DescribeProductView'
  { -- | The language code.
    --
    -- -   @en@ - English (default)
    --
    -- -   @jp@ - Japanese
    --
    -- -   @zh@ - Chinese
    DescribeProductView -> Maybe Text
acceptLanguage :: Prelude.Maybe Prelude.Text,
    -- | The product view identifier.
    DescribeProductView -> Text
id :: Prelude.Text
  }
  deriving (DescribeProductView -> DescribeProductView -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProductView -> DescribeProductView -> Bool
$c/= :: DescribeProductView -> DescribeProductView -> Bool
== :: DescribeProductView -> DescribeProductView -> Bool
$c== :: DescribeProductView -> DescribeProductView -> Bool
Prelude.Eq, ReadPrec [DescribeProductView]
ReadPrec DescribeProductView
Int -> ReadS DescribeProductView
ReadS [DescribeProductView]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProductView]
$creadListPrec :: ReadPrec [DescribeProductView]
readPrec :: ReadPrec DescribeProductView
$creadPrec :: ReadPrec DescribeProductView
readList :: ReadS [DescribeProductView]
$creadList :: ReadS [DescribeProductView]
readsPrec :: Int -> ReadS DescribeProductView
$creadsPrec :: Int -> ReadS DescribeProductView
Prelude.Read, Int -> DescribeProductView -> ShowS
[DescribeProductView] -> ShowS
DescribeProductView -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProductView] -> ShowS
$cshowList :: [DescribeProductView] -> ShowS
show :: DescribeProductView -> String
$cshow :: DescribeProductView -> String
showsPrec :: Int -> DescribeProductView -> ShowS
$cshowsPrec :: Int -> DescribeProductView -> ShowS
Prelude.Show, forall x. Rep DescribeProductView x -> DescribeProductView
forall x. DescribeProductView -> Rep DescribeProductView x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeProductView x -> DescribeProductView
$cfrom :: forall x. DescribeProductView -> Rep DescribeProductView x
Prelude.Generic)

-- |
-- Create a value of 'DescribeProductView' 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:
--
-- 'acceptLanguage', 'describeProductView_acceptLanguage' - The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
--
-- 'id', 'describeProductView_id' - The product view identifier.
newDescribeProductView ::
  -- | 'id'
  Prelude.Text ->
  DescribeProductView
newDescribeProductView :: Text -> DescribeProductView
newDescribeProductView Text
pId_ =
  DescribeProductView'
    { $sel:acceptLanguage:DescribeProductView' :: Maybe Text
acceptLanguage =
        forall a. Maybe a
Prelude.Nothing,
      $sel:id:DescribeProductView' :: Text
id = Text
pId_
    }

-- | The language code.
--
-- -   @en@ - English (default)
--
-- -   @jp@ - Japanese
--
-- -   @zh@ - Chinese
describeProductView_acceptLanguage :: Lens.Lens' DescribeProductView (Prelude.Maybe Prelude.Text)
describeProductView_acceptLanguage :: Lens' DescribeProductView (Maybe Text)
describeProductView_acceptLanguage = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductView' {Maybe Text
acceptLanguage :: Maybe Text
$sel:acceptLanguage:DescribeProductView' :: DescribeProductView -> Maybe Text
acceptLanguage} -> Maybe Text
acceptLanguage) (\s :: DescribeProductView
s@DescribeProductView' {} Maybe Text
a -> DescribeProductView
s {$sel:acceptLanguage:DescribeProductView' :: Maybe Text
acceptLanguage = Maybe Text
a} :: DescribeProductView)

-- | The product view identifier.
describeProductView_id :: Lens.Lens' DescribeProductView Prelude.Text
describeProductView_id :: Lens' DescribeProductView Text
describeProductView_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductView' {Text
id :: Text
$sel:id:DescribeProductView' :: DescribeProductView -> Text
id} -> Text
id) (\s :: DescribeProductView
s@DescribeProductView' {} Text
a -> DescribeProductView
s {$sel:id:DescribeProductView' :: Text
id = Text
a} :: DescribeProductView)

instance Core.AWSRequest DescribeProductView where
  type
    AWSResponse DescribeProductView =
      DescribeProductViewResponse
  request :: (Service -> Service)
-> DescribeProductView -> Request DescribeProductView
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 DescribeProductView
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeProductView)))
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 ProductViewSummary
-> Maybe [ProvisioningArtifact]
-> Int
-> DescribeProductViewResponse
DescribeProductViewResponse'
            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
"ProductViewSummary")
            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
"ProvisioningArtifacts"
                            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.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable DescribeProductView where
  hashWithSalt :: Int -> DescribeProductView -> Int
hashWithSalt Int
_salt DescribeProductView' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DescribeProductView' :: DescribeProductView -> Text
$sel:acceptLanguage:DescribeProductView' :: DescribeProductView -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
acceptLanguage
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id

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

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

instance Data.ToJSON DescribeProductView where
  toJSON :: DescribeProductView -> Value
toJSON DescribeProductView' {Maybe Text
Text
id :: Text
acceptLanguage :: Maybe Text
$sel:id:DescribeProductView' :: DescribeProductView -> Text
$sel:acceptLanguage:DescribeProductView' :: DescribeProductView -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"AcceptLanguage" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
acceptLanguage,
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id)
          ]
      )

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

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

-- | /See:/ 'newDescribeProductViewResponse' smart constructor.
data DescribeProductViewResponse = DescribeProductViewResponse'
  { -- | Summary information about the product.
    DescribeProductViewResponse -> Maybe ProductViewSummary
productViewSummary :: Prelude.Maybe ProductViewSummary,
    -- | Information about the provisioning artifacts for the product.
    DescribeProductViewResponse -> Maybe [ProvisioningArtifact]
provisioningArtifacts :: Prelude.Maybe [ProvisioningArtifact],
    -- | The response's http status code.
    DescribeProductViewResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeProductViewResponse -> DescribeProductViewResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeProductViewResponse -> DescribeProductViewResponse -> Bool
$c/= :: DescribeProductViewResponse -> DescribeProductViewResponse -> Bool
== :: DescribeProductViewResponse -> DescribeProductViewResponse -> Bool
$c== :: DescribeProductViewResponse -> DescribeProductViewResponse -> Bool
Prelude.Eq, ReadPrec [DescribeProductViewResponse]
ReadPrec DescribeProductViewResponse
Int -> ReadS DescribeProductViewResponse
ReadS [DescribeProductViewResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeProductViewResponse]
$creadListPrec :: ReadPrec [DescribeProductViewResponse]
readPrec :: ReadPrec DescribeProductViewResponse
$creadPrec :: ReadPrec DescribeProductViewResponse
readList :: ReadS [DescribeProductViewResponse]
$creadList :: ReadS [DescribeProductViewResponse]
readsPrec :: Int -> ReadS DescribeProductViewResponse
$creadsPrec :: Int -> ReadS DescribeProductViewResponse
Prelude.Read, Int -> DescribeProductViewResponse -> ShowS
[DescribeProductViewResponse] -> ShowS
DescribeProductViewResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeProductViewResponse] -> ShowS
$cshowList :: [DescribeProductViewResponse] -> ShowS
show :: DescribeProductViewResponse -> String
$cshow :: DescribeProductViewResponse -> String
showsPrec :: Int -> DescribeProductViewResponse -> ShowS
$cshowsPrec :: Int -> DescribeProductViewResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeProductViewResponse x -> DescribeProductViewResponse
forall x.
DescribeProductViewResponse -> Rep DescribeProductViewResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeProductViewResponse x -> DescribeProductViewResponse
$cfrom :: forall x.
DescribeProductViewResponse -> Rep DescribeProductViewResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeProductViewResponse' 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:
--
-- 'productViewSummary', 'describeProductViewResponse_productViewSummary' - Summary information about the product.
--
-- 'provisioningArtifacts', 'describeProductViewResponse_provisioningArtifacts' - Information about the provisioning artifacts for the product.
--
-- 'httpStatus', 'describeProductViewResponse_httpStatus' - The response's http status code.
newDescribeProductViewResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeProductViewResponse
newDescribeProductViewResponse :: Int -> DescribeProductViewResponse
newDescribeProductViewResponse Int
pHttpStatus_ =
  DescribeProductViewResponse'
    { $sel:productViewSummary:DescribeProductViewResponse' :: Maybe ProductViewSummary
productViewSummary =
        forall a. Maybe a
Prelude.Nothing,
      $sel:provisioningArtifacts:DescribeProductViewResponse' :: Maybe [ProvisioningArtifact]
provisioningArtifacts = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeProductViewResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Summary information about the product.
describeProductViewResponse_productViewSummary :: Lens.Lens' DescribeProductViewResponse (Prelude.Maybe ProductViewSummary)
describeProductViewResponse_productViewSummary :: Lens' DescribeProductViewResponse (Maybe ProductViewSummary)
describeProductViewResponse_productViewSummary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductViewResponse' {Maybe ProductViewSummary
productViewSummary :: Maybe ProductViewSummary
$sel:productViewSummary:DescribeProductViewResponse' :: DescribeProductViewResponse -> Maybe ProductViewSummary
productViewSummary} -> Maybe ProductViewSummary
productViewSummary) (\s :: DescribeProductViewResponse
s@DescribeProductViewResponse' {} Maybe ProductViewSummary
a -> DescribeProductViewResponse
s {$sel:productViewSummary:DescribeProductViewResponse' :: Maybe ProductViewSummary
productViewSummary = Maybe ProductViewSummary
a} :: DescribeProductViewResponse)

-- | Information about the provisioning artifacts for the product.
describeProductViewResponse_provisioningArtifacts :: Lens.Lens' DescribeProductViewResponse (Prelude.Maybe [ProvisioningArtifact])
describeProductViewResponse_provisioningArtifacts :: Lens' DescribeProductViewResponse (Maybe [ProvisioningArtifact])
describeProductViewResponse_provisioningArtifacts = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeProductViewResponse' {Maybe [ProvisioningArtifact]
provisioningArtifacts :: Maybe [ProvisioningArtifact]
$sel:provisioningArtifacts:DescribeProductViewResponse' :: DescribeProductViewResponse -> Maybe [ProvisioningArtifact]
provisioningArtifacts} -> Maybe [ProvisioningArtifact]
provisioningArtifacts) (\s :: DescribeProductViewResponse
s@DescribeProductViewResponse' {} Maybe [ProvisioningArtifact]
a -> DescribeProductViewResponse
s {$sel:provisioningArtifacts:DescribeProductViewResponse' :: Maybe [ProvisioningArtifact]
provisioningArtifacts = Maybe [ProvisioningArtifact]
a} :: DescribeProductViewResponse) 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

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

instance Prelude.NFData DescribeProductViewResponse where
  rnf :: DescribeProductViewResponse -> ()
rnf DescribeProductViewResponse' {Int
Maybe [ProvisioningArtifact]
Maybe ProductViewSummary
httpStatus :: Int
provisioningArtifacts :: Maybe [ProvisioningArtifact]
productViewSummary :: Maybe ProductViewSummary
$sel:httpStatus:DescribeProductViewResponse' :: DescribeProductViewResponse -> Int
$sel:provisioningArtifacts:DescribeProductViewResponse' :: DescribeProductViewResponse -> Maybe [ProvisioningArtifact]
$sel:productViewSummary:DescribeProductViewResponse' :: DescribeProductViewResponse -> Maybe ProductViewSummary
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ProductViewSummary
productViewSummary
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [ProvisioningArtifact]
provisioningArtifacts
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus