{-# 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.GetBucketBundles
-- 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 you can apply to a Amazon Lightsail bucket.
--
-- The bucket bundle specifies the monthly cost, storage quota, and data
-- transfer quota for a bucket.
--
-- Use the UpdateBucketBundle action to update the bundle for a bucket.
module Amazonka.Lightsail.GetBucketBundles
  ( -- * Creating a Request
    GetBucketBundles (..),
    newGetBucketBundles,

    -- * Request Lenses
    getBucketBundles_includeInactive,

    -- * Destructuring the Response
    GetBucketBundlesResponse (..),
    newGetBucketBundlesResponse,

    -- * Response Lenses
    getBucketBundlesResponse_bundles,
    getBucketBundlesResponse_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:/ 'newGetBucketBundles' smart constructor.
data GetBucketBundles = GetBucketBundles'
  { -- | A Boolean value that indicates whether to include inactive (unavailable)
    -- bundles in the response.
    GetBucketBundles -> Maybe Bool
includeInactive :: Prelude.Maybe Prelude.Bool
  }
  deriving (GetBucketBundles -> GetBucketBundles -> Bool
(GetBucketBundles -> GetBucketBundles -> Bool)
-> (GetBucketBundles -> GetBucketBundles -> Bool)
-> Eq GetBucketBundles
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetBucketBundles -> GetBucketBundles -> Bool
$c/= :: GetBucketBundles -> GetBucketBundles -> Bool
== :: GetBucketBundles -> GetBucketBundles -> Bool
$c== :: GetBucketBundles -> GetBucketBundles -> Bool
Prelude.Eq, ReadPrec [GetBucketBundles]
ReadPrec GetBucketBundles
Int -> ReadS GetBucketBundles
ReadS [GetBucketBundles]
(Int -> ReadS GetBucketBundles)
-> ReadS [GetBucketBundles]
-> ReadPrec GetBucketBundles
-> ReadPrec [GetBucketBundles]
-> Read GetBucketBundles
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetBucketBundles]
$creadListPrec :: ReadPrec [GetBucketBundles]
readPrec :: ReadPrec GetBucketBundles
$creadPrec :: ReadPrec GetBucketBundles
readList :: ReadS [GetBucketBundles]
$creadList :: ReadS [GetBucketBundles]
readsPrec :: Int -> ReadS GetBucketBundles
$creadsPrec :: Int -> ReadS GetBucketBundles
Prelude.Read, Int -> GetBucketBundles -> ShowS
[GetBucketBundles] -> ShowS
GetBucketBundles -> String
(Int -> GetBucketBundles -> ShowS)
-> (GetBucketBundles -> String)
-> ([GetBucketBundles] -> ShowS)
-> Show GetBucketBundles
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetBucketBundles] -> ShowS
$cshowList :: [GetBucketBundles] -> ShowS
show :: GetBucketBundles -> String
$cshow :: GetBucketBundles -> String
showsPrec :: Int -> GetBucketBundles -> ShowS
$cshowsPrec :: Int -> GetBucketBundles -> ShowS
Prelude.Show, (forall x. GetBucketBundles -> Rep GetBucketBundles x)
-> (forall x. Rep GetBucketBundles x -> GetBucketBundles)
-> Generic GetBucketBundles
forall x. Rep GetBucketBundles x -> GetBucketBundles
forall x. GetBucketBundles -> Rep GetBucketBundles x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetBucketBundles x -> GetBucketBundles
$cfrom :: forall x. GetBucketBundles -> Rep GetBucketBundles x
Prelude.Generic)

-- |
-- Create a value of 'GetBucketBundles' 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:
--
-- 'includeInactive', 'getBucketBundles_includeInactive' - A Boolean value that indicates whether to include inactive (unavailable)
-- bundles in the response.
newGetBucketBundles ::
  GetBucketBundles
newGetBucketBundles :: GetBucketBundles
newGetBucketBundles =
  GetBucketBundles' :: Maybe Bool -> GetBucketBundles
GetBucketBundles'
    { $sel:includeInactive:GetBucketBundles' :: Maybe Bool
includeInactive =
        Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | A Boolean value that indicates whether to include inactive (unavailable)
-- bundles in the response.
getBucketBundles_includeInactive :: Lens.Lens' GetBucketBundles (Prelude.Maybe Prelude.Bool)
getBucketBundles_includeInactive :: (Maybe Bool -> f (Maybe Bool))
-> GetBucketBundles -> f GetBucketBundles
getBucketBundles_includeInactive = (GetBucketBundles -> Maybe Bool)
-> (GetBucketBundles -> Maybe Bool -> GetBucketBundles)
-> Lens GetBucketBundles GetBucketBundles (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketBundles' {Maybe Bool
includeInactive :: Maybe Bool
$sel:includeInactive:GetBucketBundles' :: GetBucketBundles -> Maybe Bool
includeInactive} -> Maybe Bool
includeInactive) (\s :: GetBucketBundles
s@GetBucketBundles' {} Maybe Bool
a -> GetBucketBundles
s {$sel:includeInactive:GetBucketBundles' :: Maybe Bool
includeInactive = Maybe Bool
a} :: GetBucketBundles)

instance Core.AWSRequest GetBucketBundles where
  type
    AWSResponse GetBucketBundles =
      GetBucketBundlesResponse
  request :: GetBucketBundles -> Request GetBucketBundles
request = Service -> GetBucketBundles -> Request GetBucketBundles
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy GetBucketBundles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBucketBundles)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetBucketBundles))
-> Logger
-> Service
-> Proxy GetBucketBundles
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetBucketBundles)))
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 [BucketBundle] -> Int -> GetBucketBundlesResponse
GetBucketBundlesResponse'
            (Maybe [BucketBundle] -> Int -> GetBucketBundlesResponse)
-> Either String (Maybe [BucketBundle])
-> Either String (Int -> GetBucketBundlesResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Key -> Either String (Maybe (Maybe [BucketBundle]))
forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Core..?> Key
"bundles" Either String (Maybe (Maybe [BucketBundle]))
-> Maybe [BucketBundle] -> Either String (Maybe [BucketBundle])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [BucketBundle]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> GetBucketBundlesResponse)
-> Either String Int -> Either String GetBucketBundlesResponse
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 GetBucketBundles

instance Prelude.NFData GetBucketBundles

instance Core.ToHeaders GetBucketBundles where
  toHeaders :: GetBucketBundles -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetBucketBundles -> 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.GetBucketBundles" ::
                          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 GetBucketBundles where
  toJSON :: GetBucketBundles -> Value
toJSON GetBucketBundles' {Maybe Bool
includeInactive :: Maybe Bool
$sel:includeInactive:GetBucketBundles' :: GetBucketBundles -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"includeInactive" Key -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
includeInactive
          ]
      )

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

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

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

-- |
-- Create a value of 'GetBucketBundlesResponse' 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', 'getBucketBundlesResponse_bundles' - An object that describes bucket bundles.
--
-- 'httpStatus', 'getBucketBundlesResponse_httpStatus' - The response's http status code.
newGetBucketBundlesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetBucketBundlesResponse
newGetBucketBundlesResponse :: Int -> GetBucketBundlesResponse
newGetBucketBundlesResponse Int
pHttpStatus_ =
  GetBucketBundlesResponse' :: Maybe [BucketBundle] -> Int -> GetBucketBundlesResponse
GetBucketBundlesResponse'
    { $sel:bundles:GetBucketBundlesResponse' :: Maybe [BucketBundle]
bundles =
        Maybe [BucketBundle]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetBucketBundlesResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | An object that describes bucket bundles.
getBucketBundlesResponse_bundles :: Lens.Lens' GetBucketBundlesResponse (Prelude.Maybe [BucketBundle])
getBucketBundlesResponse_bundles :: (Maybe [BucketBundle] -> f (Maybe [BucketBundle]))
-> GetBucketBundlesResponse -> f GetBucketBundlesResponse
getBucketBundlesResponse_bundles = (GetBucketBundlesResponse -> Maybe [BucketBundle])
-> (GetBucketBundlesResponse
    -> Maybe [BucketBundle] -> GetBucketBundlesResponse)
-> Lens
     GetBucketBundlesResponse
     GetBucketBundlesResponse
     (Maybe [BucketBundle])
     (Maybe [BucketBundle])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetBucketBundlesResponse' {Maybe [BucketBundle]
bundles :: Maybe [BucketBundle]
$sel:bundles:GetBucketBundlesResponse' :: GetBucketBundlesResponse -> Maybe [BucketBundle]
bundles} -> Maybe [BucketBundle]
bundles) (\s :: GetBucketBundlesResponse
s@GetBucketBundlesResponse' {} Maybe [BucketBundle]
a -> GetBucketBundlesResponse
s {$sel:bundles:GetBucketBundlesResponse' :: Maybe [BucketBundle]
bundles = Maybe [BucketBundle]
a} :: GetBucketBundlesResponse) ((Maybe [BucketBundle] -> f (Maybe [BucketBundle]))
 -> GetBucketBundlesResponse -> f GetBucketBundlesResponse)
-> ((Maybe [BucketBundle] -> f (Maybe [BucketBundle]))
    -> Maybe [BucketBundle] -> f (Maybe [BucketBundle]))
-> (Maybe [BucketBundle] -> f (Maybe [BucketBundle]))
-> GetBucketBundlesResponse
-> f GetBucketBundlesResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [BucketBundle] [BucketBundle] [BucketBundle] [BucketBundle]
-> Iso
     (Maybe [BucketBundle])
     (Maybe [BucketBundle])
     (Maybe [BucketBundle])
     (Maybe [BucketBundle])
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 [BucketBundle] [BucketBundle] [BucketBundle] [BucketBundle]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance Prelude.NFData GetBucketBundlesResponse