{-# 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.Lightsail.GetDistributionBundles
-- 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 bundles that can be applied to your Amazon Lightsail content
-- delivery network (CDN) distributions.
--
-- A distribution bundle specifies the monthly network transfer quota and
-- monthly cost of your distribution.
module Amazonka.Lightsail.GetDistributionBundles
  ( -- * Creating a Request
    GetDistributionBundles (..),
    newGetDistributionBundles,

    -- * Destructuring the Response
    GetDistributionBundlesResponse (..),
    newGetDistributionBundlesResponse,

    -- * Response Lenses
    getDistributionBundlesResponse_bundles,
    getDistributionBundlesResponse_httpStatus,
  )
where

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

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

-- |
-- Create a value of 'GetDistributionBundles' 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.
newGetDistributionBundles ::
  GetDistributionBundles
newGetDistributionBundles :: GetDistributionBundles
newGetDistributionBundles = GetDistributionBundles
GetDistributionBundles'

instance Core.AWSRequest GetDistributionBundles where
  type
    AWSResponse GetDistributionBundles =
      GetDistributionBundlesResponse
  request :: (Service -> Service)
-> GetDistributionBundles -> Request GetDistributionBundles
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 GetDistributionBundles
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDistributionBundles)))
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 [DistributionBundle] -> Int -> GetDistributionBundlesResponse
GetDistributionBundlesResponse'
            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
"bundles" 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 GetDistributionBundles where
  hashWithSalt :: Int -> GetDistributionBundles -> Int
hashWithSalt Int
_salt GetDistributionBundles
_ =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` ()

instance Prelude.NFData GetDistributionBundles where
  rnf :: GetDistributionBundles -> ()
rnf GetDistributionBundles
_ = ()

instance Data.ToHeaders GetDistributionBundles where
  toHeaders :: GetDistributionBundles -> 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
"Lightsail_20161128.GetDistributionBundles" ::
                          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 GetDistributionBundles where
  toJSON :: GetDistributionBundles -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

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

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

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

-- |
-- Create a value of 'GetDistributionBundlesResponse' 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:
--
-- 'bundles', 'getDistributionBundlesResponse_bundles' - An object that describes a distribution bundle.
--
-- 'httpStatus', 'getDistributionBundlesResponse_httpStatus' - The response's http status code.
newGetDistributionBundlesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDistributionBundlesResponse
newGetDistributionBundlesResponse :: Int -> GetDistributionBundlesResponse
newGetDistributionBundlesResponse Int
pHttpStatus_ =
  GetDistributionBundlesResponse'
    { $sel:bundles:GetDistributionBundlesResponse' :: Maybe [DistributionBundle]
bundles =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDistributionBundlesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that describes a distribution bundle.
getDistributionBundlesResponse_bundles :: Lens.Lens' GetDistributionBundlesResponse (Prelude.Maybe [DistributionBundle])
getDistributionBundlesResponse_bundles :: Lens' GetDistributionBundlesResponse (Maybe [DistributionBundle])
getDistributionBundlesResponse_bundles = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionBundlesResponse' {Maybe [DistributionBundle]
bundles :: Maybe [DistributionBundle]
$sel:bundles:GetDistributionBundlesResponse' :: GetDistributionBundlesResponse -> Maybe [DistributionBundle]
bundles} -> Maybe [DistributionBundle]
bundles) (\s :: GetDistributionBundlesResponse
s@GetDistributionBundlesResponse' {} Maybe [DistributionBundle]
a -> GetDistributionBundlesResponse
s {$sel:bundles:GetDistributionBundlesResponse' :: Maybe [DistributionBundle]
bundles = Maybe [DistributionBundle]
a} :: GetDistributionBundlesResponse) 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.
getDistributionBundlesResponse_httpStatus :: Lens.Lens' GetDistributionBundlesResponse Prelude.Int
getDistributionBundlesResponse_httpStatus :: Lens' GetDistributionBundlesResponse Int
getDistributionBundlesResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDistributionBundlesResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetDistributionBundlesResponse' :: GetDistributionBundlesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetDistributionBundlesResponse
s@GetDistributionBundlesResponse' {} Int
a -> GetDistributionBundlesResponse
s {$sel:httpStatus:GetDistributionBundlesResponse' :: Int
httpStatus = Int
a} :: GetDistributionBundlesResponse)

instance
  Prelude.NFData
    GetDistributionBundlesResponse
  where
  rnf :: GetDistributionBundlesResponse -> ()
rnf GetDistributionBundlesResponse' {Int
Maybe [DistributionBundle]
httpStatus :: Int
bundles :: Maybe [DistributionBundle]
$sel:httpStatus:GetDistributionBundlesResponse' :: GetDistributionBundlesResponse -> Int
$sel:bundles:GetDistributionBundlesResponse' :: GetDistributionBundlesResponse -> Maybe [DistributionBundle]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [DistributionBundle]
bundles
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus