{-# 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.MediaConnect.DescribeOffering
-- 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)
--
-- Displays the details of an offering. The response includes the offering
-- description, duration, outbound bandwidth, price, and Amazon Resource
-- Name (ARN).
module Amazonka.MediaConnect.DescribeOffering
  ( -- * Creating a Request
    DescribeOffering (..),
    newDescribeOffering,

    -- * Request Lenses
    describeOffering_offeringArn,

    -- * Destructuring the Response
    DescribeOfferingResponse (..),
    newDescribeOfferingResponse,

    -- * Response Lenses
    describeOfferingResponse_offering,
    describeOfferingResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'DescribeOffering' 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:
--
-- 'offeringArn', 'describeOffering_offeringArn' - The Amazon Resource Name (ARN) of the offering.
newDescribeOffering ::
  -- | 'offeringArn'
  Prelude.Text ->
  DescribeOffering
newDescribeOffering :: Text -> DescribeOffering
newDescribeOffering Text
pOfferingArn_ =
  DescribeOffering' :: Text -> DescribeOffering
DescribeOffering' {$sel:offeringArn:DescribeOffering' :: Text
offeringArn = Text
pOfferingArn_}

-- | The Amazon Resource Name (ARN) of the offering.
describeOffering_offeringArn :: Lens.Lens' DescribeOffering Prelude.Text
describeOffering_offeringArn :: (Text -> f Text) -> DescribeOffering -> f DescribeOffering
describeOffering_offeringArn = (DescribeOffering -> Text)
-> (DescribeOffering -> Text -> DescribeOffering)
-> Lens DescribeOffering DescribeOffering Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOffering' {Text
offeringArn :: Text
$sel:offeringArn:DescribeOffering' :: DescribeOffering -> Text
offeringArn} -> Text
offeringArn) (\s :: DescribeOffering
s@DescribeOffering' {} Text
a -> DescribeOffering
s {$sel:offeringArn:DescribeOffering' :: Text
offeringArn = Text
a} :: DescribeOffering)

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

instance Prelude.NFData DescribeOffering

instance Core.ToHeaders DescribeOffering where
  toHeaders :: DescribeOffering -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeOffering -> 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.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToPath DescribeOffering where
  toPath :: DescribeOffering -> ByteString
toPath DescribeOffering' {Text
offeringArn :: Text
$sel:offeringArn:DescribeOffering' :: DescribeOffering -> Text
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/offerings/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
offeringArn]

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

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

-- |
-- Create a value of 'DescribeOfferingResponse' 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:
--
-- 'offering', 'describeOfferingResponse_offering' - Undocumented member.
--
-- 'httpStatus', 'describeOfferingResponse_httpStatus' - The response's http status code.
newDescribeOfferingResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeOfferingResponse
newDescribeOfferingResponse :: Int -> DescribeOfferingResponse
newDescribeOfferingResponse Int
pHttpStatus_ =
  DescribeOfferingResponse' :: Maybe Offering -> Int -> DescribeOfferingResponse
DescribeOfferingResponse'
    { $sel:offering:DescribeOfferingResponse' :: Maybe Offering
offering =
        Maybe Offering
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeOfferingResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
describeOfferingResponse_offering :: Lens.Lens' DescribeOfferingResponse (Prelude.Maybe Offering)
describeOfferingResponse_offering :: (Maybe Offering -> f (Maybe Offering))
-> DescribeOfferingResponse -> f DescribeOfferingResponse
describeOfferingResponse_offering = (DescribeOfferingResponse -> Maybe Offering)
-> (DescribeOfferingResponse
    -> Maybe Offering -> DescribeOfferingResponse)
-> Lens
     DescribeOfferingResponse
     DescribeOfferingResponse
     (Maybe Offering)
     (Maybe Offering)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeOfferingResponse' {Maybe Offering
offering :: Maybe Offering
$sel:offering:DescribeOfferingResponse' :: DescribeOfferingResponse -> Maybe Offering
offering} -> Maybe Offering
offering) (\s :: DescribeOfferingResponse
s@DescribeOfferingResponse' {} Maybe Offering
a -> DescribeOfferingResponse
s {$sel:offering:DescribeOfferingResponse' :: Maybe Offering
offering = Maybe Offering
a} :: DescribeOfferingResponse)

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

instance Prelude.NFData DescribeOfferingResponse