{-# 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.EC2.GetDefaultCreditSpecification
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Describes the default credit option for CPU usage of a burstable
-- performance instance family.
--
-- For more information, see
-- <https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/burstable-performance-instances.html Burstable performance instances>
-- in the /Amazon EC2 User Guide/.
module Amazonka.EC2.GetDefaultCreditSpecification
  ( -- * Creating a Request
    GetDefaultCreditSpecification (..),
    newGetDefaultCreditSpecification,

    -- * Request Lenses
    getDefaultCreditSpecification_dryRun,
    getDefaultCreditSpecification_instanceFamily,

    -- * Destructuring the Response
    GetDefaultCreditSpecificationResponse (..),
    newGetDefaultCreditSpecificationResponse,

    -- * Response Lenses
    getDefaultCreditSpecificationResponse_instanceFamilyCreditSpecification,
    getDefaultCreditSpecificationResponse_httpStatus,
  )
where

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

-- | /See:/ 'newGetDefaultCreditSpecification' smart constructor.
data GetDefaultCreditSpecification = GetDefaultCreditSpecification'
  { -- | Checks whether you have the required permissions for the action, without
    -- actually making the request, and provides an error response. If you have
    -- the required permissions, the error response is @DryRunOperation@.
    -- Otherwise, it is @UnauthorizedOperation@.
    GetDefaultCreditSpecification -> Maybe Bool
dryRun :: Prelude.Maybe Prelude.Bool,
    -- | The instance family.
    GetDefaultCreditSpecification -> UnlimitedSupportedInstanceFamily
instanceFamily :: UnlimitedSupportedInstanceFamily
  }
  deriving (GetDefaultCreditSpecification
-> GetDefaultCreditSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDefaultCreditSpecification
-> GetDefaultCreditSpecification -> Bool
$c/= :: GetDefaultCreditSpecification
-> GetDefaultCreditSpecification -> Bool
== :: GetDefaultCreditSpecification
-> GetDefaultCreditSpecification -> Bool
$c== :: GetDefaultCreditSpecification
-> GetDefaultCreditSpecification -> Bool
Prelude.Eq, ReadPrec [GetDefaultCreditSpecification]
ReadPrec GetDefaultCreditSpecification
Int -> ReadS GetDefaultCreditSpecification
ReadS [GetDefaultCreditSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDefaultCreditSpecification]
$creadListPrec :: ReadPrec [GetDefaultCreditSpecification]
readPrec :: ReadPrec GetDefaultCreditSpecification
$creadPrec :: ReadPrec GetDefaultCreditSpecification
readList :: ReadS [GetDefaultCreditSpecification]
$creadList :: ReadS [GetDefaultCreditSpecification]
readsPrec :: Int -> ReadS GetDefaultCreditSpecification
$creadsPrec :: Int -> ReadS GetDefaultCreditSpecification
Prelude.Read, Int -> GetDefaultCreditSpecification -> ShowS
[GetDefaultCreditSpecification] -> ShowS
GetDefaultCreditSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDefaultCreditSpecification] -> ShowS
$cshowList :: [GetDefaultCreditSpecification] -> ShowS
show :: GetDefaultCreditSpecification -> String
$cshow :: GetDefaultCreditSpecification -> String
showsPrec :: Int -> GetDefaultCreditSpecification -> ShowS
$cshowsPrec :: Int -> GetDefaultCreditSpecification -> ShowS
Prelude.Show, forall x.
Rep GetDefaultCreditSpecification x
-> GetDefaultCreditSpecification
forall x.
GetDefaultCreditSpecification
-> Rep GetDefaultCreditSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDefaultCreditSpecification x
-> GetDefaultCreditSpecification
$cfrom :: forall x.
GetDefaultCreditSpecification
-> Rep GetDefaultCreditSpecification x
Prelude.Generic)

-- |
-- Create a value of 'GetDefaultCreditSpecification' 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:
--
-- 'dryRun', 'getDefaultCreditSpecification_dryRun' - Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
--
-- 'instanceFamily', 'getDefaultCreditSpecification_instanceFamily' - The instance family.
newGetDefaultCreditSpecification ::
  -- | 'instanceFamily'
  UnlimitedSupportedInstanceFamily ->
  GetDefaultCreditSpecification
newGetDefaultCreditSpecification :: UnlimitedSupportedInstanceFamily -> GetDefaultCreditSpecification
newGetDefaultCreditSpecification UnlimitedSupportedInstanceFamily
pInstanceFamily_ =
  GetDefaultCreditSpecification'
    { $sel:dryRun:GetDefaultCreditSpecification' :: Maybe Bool
dryRun =
        forall a. Maybe a
Prelude.Nothing,
      $sel:instanceFamily:GetDefaultCreditSpecification' :: UnlimitedSupportedInstanceFamily
instanceFamily = UnlimitedSupportedInstanceFamily
pInstanceFamily_
    }

-- | Checks whether you have the required permissions for the action, without
-- actually making the request, and provides an error response. If you have
-- the required permissions, the error response is @DryRunOperation@.
-- Otherwise, it is @UnauthorizedOperation@.
getDefaultCreditSpecification_dryRun :: Lens.Lens' GetDefaultCreditSpecification (Prelude.Maybe Prelude.Bool)
getDefaultCreditSpecification_dryRun :: Lens' GetDefaultCreditSpecification (Maybe Bool)
getDefaultCreditSpecification_dryRun = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDefaultCreditSpecification' {Maybe Bool
dryRun :: Maybe Bool
$sel:dryRun:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> Maybe Bool
dryRun} -> Maybe Bool
dryRun) (\s :: GetDefaultCreditSpecification
s@GetDefaultCreditSpecification' {} Maybe Bool
a -> GetDefaultCreditSpecification
s {$sel:dryRun:GetDefaultCreditSpecification' :: Maybe Bool
dryRun = Maybe Bool
a} :: GetDefaultCreditSpecification)

-- | The instance family.
getDefaultCreditSpecification_instanceFamily :: Lens.Lens' GetDefaultCreditSpecification UnlimitedSupportedInstanceFamily
getDefaultCreditSpecification_instanceFamily :: Lens'
  GetDefaultCreditSpecification UnlimitedSupportedInstanceFamily
getDefaultCreditSpecification_instanceFamily = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDefaultCreditSpecification' {UnlimitedSupportedInstanceFamily
instanceFamily :: UnlimitedSupportedInstanceFamily
$sel:instanceFamily:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> UnlimitedSupportedInstanceFamily
instanceFamily} -> UnlimitedSupportedInstanceFamily
instanceFamily) (\s :: GetDefaultCreditSpecification
s@GetDefaultCreditSpecification' {} UnlimitedSupportedInstanceFamily
a -> GetDefaultCreditSpecification
s {$sel:instanceFamily:GetDefaultCreditSpecification' :: UnlimitedSupportedInstanceFamily
instanceFamily = UnlimitedSupportedInstanceFamily
a} :: GetDefaultCreditSpecification)

instance
  Core.AWSRequest
    GetDefaultCreditSpecification
  where
  type
    AWSResponse GetDefaultCreditSpecification =
      GetDefaultCreditSpecificationResponse
  request :: (Service -> Service)
-> GetDefaultCreditSpecification
-> Request GetDefaultCreditSpecification
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetDefaultCreditSpecification
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDefaultCreditSpecification)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXML
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe InstanceFamilyCreditSpecification
-> Int -> GetDefaultCreditSpecificationResponse
GetDefaultCreditSpecificationResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"instanceFamilyCreditSpecification")
            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
    GetDefaultCreditSpecification
  where
  hashWithSalt :: Int -> GetDefaultCreditSpecification -> Int
hashWithSalt Int
_salt GetDefaultCreditSpecification' {Maybe Bool
UnlimitedSupportedInstanceFamily
instanceFamily :: UnlimitedSupportedInstanceFamily
dryRun :: Maybe Bool
$sel:instanceFamily:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> UnlimitedSupportedInstanceFamily
$sel:dryRun:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
dryRun
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` UnlimitedSupportedInstanceFamily
instanceFamily

instance Prelude.NFData GetDefaultCreditSpecification where
  rnf :: GetDefaultCreditSpecification -> ()
rnf GetDefaultCreditSpecification' {Maybe Bool
UnlimitedSupportedInstanceFamily
instanceFamily :: UnlimitedSupportedInstanceFamily
dryRun :: Maybe Bool
$sel:instanceFamily:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> UnlimitedSupportedInstanceFamily
$sel:dryRun:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
dryRun
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf UnlimitedSupportedInstanceFamily
instanceFamily

instance Data.ToHeaders GetDefaultCreditSpecification where
  toHeaders :: GetDefaultCreditSpecification -> ResponseHeaders
toHeaders = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

instance Data.ToQuery GetDefaultCreditSpecification where
  toQuery :: GetDefaultCreditSpecification -> QueryString
toQuery GetDefaultCreditSpecification' {Maybe Bool
UnlimitedSupportedInstanceFamily
instanceFamily :: UnlimitedSupportedInstanceFamily
dryRun :: Maybe Bool
$sel:instanceFamily:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> UnlimitedSupportedInstanceFamily
$sel:dryRun:GetDefaultCreditSpecification' :: GetDefaultCreditSpecification -> Maybe Bool
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: ( ByteString
"GetDefaultCreditSpecification" ::
                      Prelude.ByteString
                  ),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2016-11-15" :: Prelude.ByteString),
        ByteString
"DryRun" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Bool
dryRun,
        ByteString
"InstanceFamily" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: UnlimitedSupportedInstanceFamily
instanceFamily
      ]

-- | /See:/ 'newGetDefaultCreditSpecificationResponse' smart constructor.
data GetDefaultCreditSpecificationResponse = GetDefaultCreditSpecificationResponse'
  { -- | The default credit option for CPU usage of the instance family.
    GetDefaultCreditSpecificationResponse
-> Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification :: Prelude.Maybe InstanceFamilyCreditSpecification,
    -- | The response's http status code.
    GetDefaultCreditSpecificationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (GetDefaultCreditSpecificationResponse
-> GetDefaultCreditSpecificationResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDefaultCreditSpecificationResponse
-> GetDefaultCreditSpecificationResponse -> Bool
$c/= :: GetDefaultCreditSpecificationResponse
-> GetDefaultCreditSpecificationResponse -> Bool
== :: GetDefaultCreditSpecificationResponse
-> GetDefaultCreditSpecificationResponse -> Bool
$c== :: GetDefaultCreditSpecificationResponse
-> GetDefaultCreditSpecificationResponse -> Bool
Prelude.Eq, ReadPrec [GetDefaultCreditSpecificationResponse]
ReadPrec GetDefaultCreditSpecificationResponse
Int -> ReadS GetDefaultCreditSpecificationResponse
ReadS [GetDefaultCreditSpecificationResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDefaultCreditSpecificationResponse]
$creadListPrec :: ReadPrec [GetDefaultCreditSpecificationResponse]
readPrec :: ReadPrec GetDefaultCreditSpecificationResponse
$creadPrec :: ReadPrec GetDefaultCreditSpecificationResponse
readList :: ReadS [GetDefaultCreditSpecificationResponse]
$creadList :: ReadS [GetDefaultCreditSpecificationResponse]
readsPrec :: Int -> ReadS GetDefaultCreditSpecificationResponse
$creadsPrec :: Int -> ReadS GetDefaultCreditSpecificationResponse
Prelude.Read, Int -> GetDefaultCreditSpecificationResponse -> ShowS
[GetDefaultCreditSpecificationResponse] -> ShowS
GetDefaultCreditSpecificationResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDefaultCreditSpecificationResponse] -> ShowS
$cshowList :: [GetDefaultCreditSpecificationResponse] -> ShowS
show :: GetDefaultCreditSpecificationResponse -> String
$cshow :: GetDefaultCreditSpecificationResponse -> String
showsPrec :: Int -> GetDefaultCreditSpecificationResponse -> ShowS
$cshowsPrec :: Int -> GetDefaultCreditSpecificationResponse -> ShowS
Prelude.Show, forall x.
Rep GetDefaultCreditSpecificationResponse x
-> GetDefaultCreditSpecificationResponse
forall x.
GetDefaultCreditSpecificationResponse
-> Rep GetDefaultCreditSpecificationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GetDefaultCreditSpecificationResponse x
-> GetDefaultCreditSpecificationResponse
$cfrom :: forall x.
GetDefaultCreditSpecificationResponse
-> Rep GetDefaultCreditSpecificationResponse x
Prelude.Generic)

-- |
-- Create a value of 'GetDefaultCreditSpecificationResponse' 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:
--
-- 'instanceFamilyCreditSpecification', 'getDefaultCreditSpecificationResponse_instanceFamilyCreditSpecification' - The default credit option for CPU usage of the instance family.
--
-- 'httpStatus', 'getDefaultCreditSpecificationResponse_httpStatus' - The response's http status code.
newGetDefaultCreditSpecificationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetDefaultCreditSpecificationResponse
newGetDefaultCreditSpecificationResponse :: Int -> GetDefaultCreditSpecificationResponse
newGetDefaultCreditSpecificationResponse Int
pHttpStatus_ =
  GetDefaultCreditSpecificationResponse'
    { $sel:instanceFamilyCreditSpecification:GetDefaultCreditSpecificationResponse' :: Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetDefaultCreditSpecificationResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The default credit option for CPU usage of the instance family.
getDefaultCreditSpecificationResponse_instanceFamilyCreditSpecification :: Lens.Lens' GetDefaultCreditSpecificationResponse (Prelude.Maybe InstanceFamilyCreditSpecification)
getDefaultCreditSpecificationResponse_instanceFamilyCreditSpecification :: Lens'
  GetDefaultCreditSpecificationResponse
  (Maybe InstanceFamilyCreditSpecification)
getDefaultCreditSpecificationResponse_instanceFamilyCreditSpecification = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDefaultCreditSpecificationResponse' {Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification :: Maybe InstanceFamilyCreditSpecification
$sel:instanceFamilyCreditSpecification:GetDefaultCreditSpecificationResponse' :: GetDefaultCreditSpecificationResponse
-> Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification} -> Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification) (\s :: GetDefaultCreditSpecificationResponse
s@GetDefaultCreditSpecificationResponse' {} Maybe InstanceFamilyCreditSpecification
a -> GetDefaultCreditSpecificationResponse
s {$sel:instanceFamilyCreditSpecification:GetDefaultCreditSpecificationResponse' :: Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification = Maybe InstanceFamilyCreditSpecification
a} :: GetDefaultCreditSpecificationResponse)

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

instance
  Prelude.NFData
    GetDefaultCreditSpecificationResponse
  where
  rnf :: GetDefaultCreditSpecificationResponse -> ()
rnf GetDefaultCreditSpecificationResponse' {Int
Maybe InstanceFamilyCreditSpecification
httpStatus :: Int
instanceFamilyCreditSpecification :: Maybe InstanceFamilyCreditSpecification
$sel:httpStatus:GetDefaultCreditSpecificationResponse' :: GetDefaultCreditSpecificationResponse -> Int
$sel:instanceFamilyCreditSpecification:GetDefaultCreditSpecificationResponse' :: GetDefaultCreditSpecificationResponse
-> Maybe InstanceFamilyCreditSpecification
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe InstanceFamilyCreditSpecification
instanceFamilyCreditSpecification
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus