{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.SpotPlacementScore
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EC2.Types.SpotPlacementScore where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EC2.Internal
import qualified Amazonka.Prelude as Prelude

-- | The Spot placement score for this Region or Availability Zone. The score
-- is calculated based on the assumption that the @capacity-optimized@
-- allocation strategy is used and that all of the Availability Zones in
-- the Region can be used.
--
-- /See:/ 'newSpotPlacementScore' smart constructor.
data SpotPlacementScore = SpotPlacementScore'
  { -- | The Availability Zone.
    SpotPlacementScore -> Maybe Text
availabilityZoneId :: Prelude.Maybe Prelude.Text,
    -- | The Region.
    SpotPlacementScore -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The placement score, on a scale from @1@ to @10@. A score of @10@
    -- indicates that your Spot request is highly likely to succeed in this
    -- Region or Availability Zone. A score of @1@ indicates that your Spot
    -- request is not likely to succeed.
    SpotPlacementScore -> Maybe Int
score :: Prelude.Maybe Prelude.Int
  }
  deriving (SpotPlacementScore -> SpotPlacementScore -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SpotPlacementScore -> SpotPlacementScore -> Bool
$c/= :: SpotPlacementScore -> SpotPlacementScore -> Bool
== :: SpotPlacementScore -> SpotPlacementScore -> Bool
$c== :: SpotPlacementScore -> SpotPlacementScore -> Bool
Prelude.Eq, ReadPrec [SpotPlacementScore]
ReadPrec SpotPlacementScore
Int -> ReadS SpotPlacementScore
ReadS [SpotPlacementScore]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SpotPlacementScore]
$creadListPrec :: ReadPrec [SpotPlacementScore]
readPrec :: ReadPrec SpotPlacementScore
$creadPrec :: ReadPrec SpotPlacementScore
readList :: ReadS [SpotPlacementScore]
$creadList :: ReadS [SpotPlacementScore]
readsPrec :: Int -> ReadS SpotPlacementScore
$creadsPrec :: Int -> ReadS SpotPlacementScore
Prelude.Read, Int -> SpotPlacementScore -> ShowS
[SpotPlacementScore] -> ShowS
SpotPlacementScore -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SpotPlacementScore] -> ShowS
$cshowList :: [SpotPlacementScore] -> ShowS
show :: SpotPlacementScore -> String
$cshow :: SpotPlacementScore -> String
showsPrec :: Int -> SpotPlacementScore -> ShowS
$cshowsPrec :: Int -> SpotPlacementScore -> ShowS
Prelude.Show, forall x. Rep SpotPlacementScore x -> SpotPlacementScore
forall x. SpotPlacementScore -> Rep SpotPlacementScore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SpotPlacementScore x -> SpotPlacementScore
$cfrom :: forall x. SpotPlacementScore -> Rep SpotPlacementScore x
Prelude.Generic)

-- |
-- Create a value of 'SpotPlacementScore' 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:
--
-- 'availabilityZoneId', 'spotPlacementScore_availabilityZoneId' - The Availability Zone.
--
-- 'region', 'spotPlacementScore_region' - The Region.
--
-- 'score', 'spotPlacementScore_score' - The placement score, on a scale from @1@ to @10@. A score of @10@
-- indicates that your Spot request is highly likely to succeed in this
-- Region or Availability Zone. A score of @1@ indicates that your Spot
-- request is not likely to succeed.
newSpotPlacementScore ::
  SpotPlacementScore
newSpotPlacementScore :: SpotPlacementScore
newSpotPlacementScore =
  SpotPlacementScore'
    { $sel:availabilityZoneId:SpotPlacementScore' :: Maybe Text
availabilityZoneId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:region:SpotPlacementScore' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing,
      $sel:score:SpotPlacementScore' :: Maybe Int
score = forall a. Maybe a
Prelude.Nothing
    }

-- | The Availability Zone.
spotPlacementScore_availabilityZoneId :: Lens.Lens' SpotPlacementScore (Prelude.Maybe Prelude.Text)
spotPlacementScore_availabilityZoneId :: Lens' SpotPlacementScore (Maybe Text)
spotPlacementScore_availabilityZoneId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPlacementScore' {Maybe Text
availabilityZoneId :: Maybe Text
$sel:availabilityZoneId:SpotPlacementScore' :: SpotPlacementScore -> Maybe Text
availabilityZoneId} -> Maybe Text
availabilityZoneId) (\s :: SpotPlacementScore
s@SpotPlacementScore' {} Maybe Text
a -> SpotPlacementScore
s {$sel:availabilityZoneId:SpotPlacementScore' :: Maybe Text
availabilityZoneId = Maybe Text
a} :: SpotPlacementScore)

-- | The Region.
spotPlacementScore_region :: Lens.Lens' SpotPlacementScore (Prelude.Maybe Prelude.Text)
spotPlacementScore_region :: Lens' SpotPlacementScore (Maybe Text)
spotPlacementScore_region = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPlacementScore' {Maybe Text
region :: Maybe Text
$sel:region:SpotPlacementScore' :: SpotPlacementScore -> Maybe Text
region} -> Maybe Text
region) (\s :: SpotPlacementScore
s@SpotPlacementScore' {} Maybe Text
a -> SpotPlacementScore
s {$sel:region:SpotPlacementScore' :: Maybe Text
region = Maybe Text
a} :: SpotPlacementScore)

-- | The placement score, on a scale from @1@ to @10@. A score of @10@
-- indicates that your Spot request is highly likely to succeed in this
-- Region or Availability Zone. A score of @1@ indicates that your Spot
-- request is not likely to succeed.
spotPlacementScore_score :: Lens.Lens' SpotPlacementScore (Prelude.Maybe Prelude.Int)
spotPlacementScore_score :: Lens' SpotPlacementScore (Maybe Int)
spotPlacementScore_score = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SpotPlacementScore' {Maybe Int
score :: Maybe Int
$sel:score:SpotPlacementScore' :: SpotPlacementScore -> Maybe Int
score} -> Maybe Int
score) (\s :: SpotPlacementScore
s@SpotPlacementScore' {} Maybe Int
a -> SpotPlacementScore
s {$sel:score:SpotPlacementScore' :: Maybe Int
score = Maybe Int
a} :: SpotPlacementScore)

instance Data.FromXML SpotPlacementScore where
  parseXML :: [Node] -> Either String SpotPlacementScore
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Int -> SpotPlacementScore
SpotPlacementScore'
      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
"availabilityZoneId")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"region")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"score")

instance Prelude.Hashable SpotPlacementScore where
  hashWithSalt :: Int -> SpotPlacementScore -> Int
hashWithSalt Int
_salt SpotPlacementScore' {Maybe Int
Maybe Text
score :: Maybe Int
region :: Maybe Text
availabilityZoneId :: Maybe Text
$sel:score:SpotPlacementScore' :: SpotPlacementScore -> Maybe Int
$sel:region:SpotPlacementScore' :: SpotPlacementScore -> Maybe Text
$sel:availabilityZoneId:SpotPlacementScore' :: SpotPlacementScore -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
availabilityZoneId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
score

instance Prelude.NFData SpotPlacementScore where
  rnf :: SpotPlacementScore -> ()
rnf SpotPlacementScore' {Maybe Int
Maybe Text
score :: Maybe Int
region :: Maybe Text
availabilityZoneId :: Maybe Text
$sel:score:SpotPlacementScore' :: SpotPlacementScore -> Maybe Int
$sel:region:SpotPlacementScore' :: SpotPlacementScore -> Maybe Text
$sel:availabilityZoneId:SpotPlacementScore' :: SpotPlacementScore -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
availabilityZoneId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
score