{-# 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-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)
--
-- 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 dsitribution.
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.Lens as Lens
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
(GetDistributionBundles -> GetDistributionBundles -> Bool)
-> (GetDistributionBundles -> GetDistributionBundles -> Bool)
-> Eq GetDistributionBundles
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]
(Int -> ReadS GetDistributionBundles)
-> ReadS [GetDistributionBundles]
-> ReadPrec GetDistributionBundles
-> ReadPrec [GetDistributionBundles]
-> Read 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
(Int -> GetDistributionBundles -> ShowS)
-> (GetDistributionBundles -> String)
-> ([GetDistributionBundles] -> ShowS)
-> Show GetDistributionBundles
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. GetDistributionBundles -> Rep GetDistributionBundles x)
-> (forall x.
    Rep GetDistributionBundles x -> GetDistributionBundles)
-> Generic GetDistributionBundles
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 :: GetDistributionBundles -> Request GetDistributionBundles
request = Service -> GetDistributionBundles -> Request GetDistributionBundles
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetDistributionBundles
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDistributionBundles)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetDistributionBundles))
-> Logger
-> Service
-> Proxy GetDistributionBundles
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDistributionBundles)))
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 [DistributionBundle] -> Int -> GetDistributionBundlesResponse
GetDistributionBundlesResponse'
            (Maybe [DistributionBundle]
 -> Int -> GetDistributionBundlesResponse)
-> Either String (Maybe [DistributionBundle])
-> Either String (Int -> GetDistributionBundlesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe (Maybe [DistributionBundle]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"bundles" Either String (Maybe (Maybe [DistributionBundle]))
-> Maybe [DistributionBundle]
-> Either String (Maybe [DistributionBundle])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [DistributionBundle]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetDistributionBundlesResponse)
-> Either String Int
-> Either String GetDistributionBundlesResponse
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 GetDistributionBundles

instance Prelude.NFData GetDistributionBundles

instance Core.ToHeaders GetDistributionBundles where
  toHeaders :: GetDistributionBundles -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDistributionBundles -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"Lightsail_20161128.GetDistributionBundles" ::
                          Prelude.ByteString
                      ),
            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.ToJSON GetDistributionBundles where
  toJSON :: GetDistributionBundles -> Value
toJSON = Value -> GetDistributionBundles -> Value
forall a b. a -> b -> a
Prelude.const (Object -> Value
Core.Object Object
forall a. Monoid a => a
Prelude.mempty)

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

instance Core.ToQuery GetDistributionBundles where
  toQuery :: GetDistributionBundles -> QueryString
toQuery = QueryString -> GetDistributionBundles -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(GetDistributionBundlesResponse
 -> GetDistributionBundlesResponse -> Bool)
-> (GetDistributionBundlesResponse
    -> GetDistributionBundlesResponse -> Bool)
-> Eq GetDistributionBundlesResponse
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]
(Int -> ReadS GetDistributionBundlesResponse)
-> ReadS [GetDistributionBundlesResponse]
-> ReadPrec GetDistributionBundlesResponse
-> ReadPrec [GetDistributionBundlesResponse]
-> Read 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
(Int -> GetDistributionBundlesResponse -> ShowS)
-> (GetDistributionBundlesResponse -> String)
-> ([GetDistributionBundlesResponse] -> ShowS)
-> Show GetDistributionBundlesResponse
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.
 GetDistributionBundlesResponse
 -> Rep GetDistributionBundlesResponse x)
-> (forall x.
    Rep GetDistributionBundlesResponse x
    -> GetDistributionBundlesResponse)
-> Generic GetDistributionBundlesResponse
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' :: Maybe [DistributionBundle] -> Int -> GetDistributionBundlesResponse
GetDistributionBundlesResponse'
    { $sel:bundles:GetDistributionBundlesResponse' :: Maybe [DistributionBundle]
bundles =
        Maybe [DistributionBundle]
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 :: (Maybe [DistributionBundle] -> f (Maybe [DistributionBundle]))
-> GetDistributionBundlesResponse
-> f GetDistributionBundlesResponse
getDistributionBundlesResponse_bundles = (GetDistributionBundlesResponse -> Maybe [DistributionBundle])
-> (GetDistributionBundlesResponse
    -> Maybe [DistributionBundle] -> GetDistributionBundlesResponse)
-> Lens
     GetDistributionBundlesResponse
     GetDistributionBundlesResponse
     (Maybe [DistributionBundle])
     (Maybe [DistributionBundle])
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) ((Maybe [DistributionBundle] -> f (Maybe [DistributionBundle]))
 -> GetDistributionBundlesResponse
 -> f GetDistributionBundlesResponse)
-> ((Maybe [DistributionBundle] -> f (Maybe [DistributionBundle]))
    -> Maybe [DistributionBundle] -> f (Maybe [DistributionBundle]))
-> (Maybe [DistributionBundle] -> f (Maybe [DistributionBundle]))
-> GetDistributionBundlesResponse
-> f GetDistributionBundlesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [DistributionBundle]
  [DistributionBundle]
  [DistributionBundle]
  [DistributionBundle]
-> Iso
     (Maybe [DistributionBundle])
     (Maybe [DistributionBundle])
     (Maybe [DistributionBundle])
     (Maybe [DistributionBundle])
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 AnIso
  [DistributionBundle]
  [DistributionBundle]
  [DistributionBundle]
  [DistributionBundle]
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 :: (Int -> f Int)
-> GetDistributionBundlesResponse
-> f GetDistributionBundlesResponse
getDistributionBundlesResponse_httpStatus = (GetDistributionBundlesResponse -> Int)
-> (GetDistributionBundlesResponse
    -> Int -> GetDistributionBundlesResponse)
-> Lens
     GetDistributionBundlesResponse
     GetDistributionBundlesResponse
     Int
     Int
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