{-# 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.CostExplorer.Types.ReservationUtilizationGroup
-- 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)
module Amazonka.CostExplorer.Types.ReservationUtilizationGroup where

import qualified Amazonka.Core as Core
import Amazonka.CostExplorer.Types.ReservationAggregates
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A group of reservations that share a set of attributes.
--
-- /See:/ 'newReservationUtilizationGroup' smart constructor.
data ReservationUtilizationGroup = ReservationUtilizationGroup'
  { -- | The value of a specific reservation attribute.
    ReservationUtilizationGroup -> Maybe Text
value :: Prelude.Maybe Prelude.Text,
    -- | The key for a specific reservation attribute.
    ReservationUtilizationGroup -> Maybe Text
key :: Prelude.Maybe Prelude.Text,
    -- | The attributes for this group of reservations.
    ReservationUtilizationGroup -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | How much you used this group of reservations.
    ReservationUtilizationGroup -> Maybe ReservationAggregates
utilization :: Prelude.Maybe ReservationAggregates
  }
  deriving (ReservationUtilizationGroup -> ReservationUtilizationGroup -> Bool
(ReservationUtilizationGroup
 -> ReservationUtilizationGroup -> Bool)
-> (ReservationUtilizationGroup
    -> ReservationUtilizationGroup -> Bool)
-> Eq ReservationUtilizationGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReservationUtilizationGroup -> ReservationUtilizationGroup -> Bool
$c/= :: ReservationUtilizationGroup -> ReservationUtilizationGroup -> Bool
== :: ReservationUtilizationGroup -> ReservationUtilizationGroup -> Bool
$c== :: ReservationUtilizationGroup -> ReservationUtilizationGroup -> Bool
Prelude.Eq, ReadPrec [ReservationUtilizationGroup]
ReadPrec ReservationUtilizationGroup
Int -> ReadS ReservationUtilizationGroup
ReadS [ReservationUtilizationGroup]
(Int -> ReadS ReservationUtilizationGroup)
-> ReadS [ReservationUtilizationGroup]
-> ReadPrec ReservationUtilizationGroup
-> ReadPrec [ReservationUtilizationGroup]
-> Read ReservationUtilizationGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReservationUtilizationGroup]
$creadListPrec :: ReadPrec [ReservationUtilizationGroup]
readPrec :: ReadPrec ReservationUtilizationGroup
$creadPrec :: ReadPrec ReservationUtilizationGroup
readList :: ReadS [ReservationUtilizationGroup]
$creadList :: ReadS [ReservationUtilizationGroup]
readsPrec :: Int -> ReadS ReservationUtilizationGroup
$creadsPrec :: Int -> ReadS ReservationUtilizationGroup
Prelude.Read, Int -> ReservationUtilizationGroup -> ShowS
[ReservationUtilizationGroup] -> ShowS
ReservationUtilizationGroup -> String
(Int -> ReservationUtilizationGroup -> ShowS)
-> (ReservationUtilizationGroup -> String)
-> ([ReservationUtilizationGroup] -> ShowS)
-> Show ReservationUtilizationGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReservationUtilizationGroup] -> ShowS
$cshowList :: [ReservationUtilizationGroup] -> ShowS
show :: ReservationUtilizationGroup -> String
$cshow :: ReservationUtilizationGroup -> String
showsPrec :: Int -> ReservationUtilizationGroup -> ShowS
$cshowsPrec :: Int -> ReservationUtilizationGroup -> ShowS
Prelude.Show, (forall x.
 ReservationUtilizationGroup -> Rep ReservationUtilizationGroup x)
-> (forall x.
    Rep ReservationUtilizationGroup x -> ReservationUtilizationGroup)
-> Generic ReservationUtilizationGroup
forall x.
Rep ReservationUtilizationGroup x -> ReservationUtilizationGroup
forall x.
ReservationUtilizationGroup -> Rep ReservationUtilizationGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReservationUtilizationGroup x -> ReservationUtilizationGroup
$cfrom :: forall x.
ReservationUtilizationGroup -> Rep ReservationUtilizationGroup x
Prelude.Generic)

-- |
-- Create a value of 'ReservationUtilizationGroup' 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:
--
-- 'value', 'reservationUtilizationGroup_value' - The value of a specific reservation attribute.
--
-- 'key', 'reservationUtilizationGroup_key' - The key for a specific reservation attribute.
--
-- 'attributes', 'reservationUtilizationGroup_attributes' - The attributes for this group of reservations.
--
-- 'utilization', 'reservationUtilizationGroup_utilization' - How much you used this group of reservations.
newReservationUtilizationGroup ::
  ReservationUtilizationGroup
newReservationUtilizationGroup :: ReservationUtilizationGroup
newReservationUtilizationGroup =
  ReservationUtilizationGroup' :: Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe ReservationAggregates
-> ReservationUtilizationGroup
ReservationUtilizationGroup'
    { $sel:value:ReservationUtilizationGroup' :: Maybe Text
value =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:key:ReservationUtilizationGroup' :: Maybe Text
key = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:ReservationUtilizationGroup' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:utilization:ReservationUtilizationGroup' :: Maybe ReservationAggregates
utilization = Maybe ReservationAggregates
forall a. Maybe a
Prelude.Nothing
    }

-- | The value of a specific reservation attribute.
reservationUtilizationGroup_value :: Lens.Lens' ReservationUtilizationGroup (Prelude.Maybe Prelude.Text)
reservationUtilizationGroup_value :: (Maybe Text -> f (Maybe Text))
-> ReservationUtilizationGroup -> f ReservationUtilizationGroup
reservationUtilizationGroup_value = (ReservationUtilizationGroup -> Maybe Text)
-> (ReservationUtilizationGroup
    -> Maybe Text -> ReservationUtilizationGroup)
-> Lens
     ReservationUtilizationGroup
     ReservationUtilizationGroup
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationUtilizationGroup' {Maybe Text
value :: Maybe Text
$sel:value:ReservationUtilizationGroup' :: ReservationUtilizationGroup -> Maybe Text
value} -> Maybe Text
value) (\s :: ReservationUtilizationGroup
s@ReservationUtilizationGroup' {} Maybe Text
a -> ReservationUtilizationGroup
s {$sel:value:ReservationUtilizationGroup' :: Maybe Text
value = Maybe Text
a} :: ReservationUtilizationGroup)

-- | The key for a specific reservation attribute.
reservationUtilizationGroup_key :: Lens.Lens' ReservationUtilizationGroup (Prelude.Maybe Prelude.Text)
reservationUtilizationGroup_key :: (Maybe Text -> f (Maybe Text))
-> ReservationUtilizationGroup -> f ReservationUtilizationGroup
reservationUtilizationGroup_key = (ReservationUtilizationGroup -> Maybe Text)
-> (ReservationUtilizationGroup
    -> Maybe Text -> ReservationUtilizationGroup)
-> Lens
     ReservationUtilizationGroup
     ReservationUtilizationGroup
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationUtilizationGroup' {Maybe Text
key :: Maybe Text
$sel:key:ReservationUtilizationGroup' :: ReservationUtilizationGroup -> Maybe Text
key} -> Maybe Text
key) (\s :: ReservationUtilizationGroup
s@ReservationUtilizationGroup' {} Maybe Text
a -> ReservationUtilizationGroup
s {$sel:key:ReservationUtilizationGroup' :: Maybe Text
key = Maybe Text
a} :: ReservationUtilizationGroup)

-- | The attributes for this group of reservations.
reservationUtilizationGroup_attributes :: Lens.Lens' ReservationUtilizationGroup (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
reservationUtilizationGroup_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ReservationUtilizationGroup -> f ReservationUtilizationGroup
reservationUtilizationGroup_attributes = (ReservationUtilizationGroup -> Maybe (HashMap Text Text))
-> (ReservationUtilizationGroup
    -> Maybe (HashMap Text Text) -> ReservationUtilizationGroup)
-> Lens
     ReservationUtilizationGroup
     ReservationUtilizationGroup
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationUtilizationGroup' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:ReservationUtilizationGroup' :: ReservationUtilizationGroup -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: ReservationUtilizationGroup
s@ReservationUtilizationGroup' {} Maybe (HashMap Text Text)
a -> ReservationUtilizationGroup
s {$sel:attributes:ReservationUtilizationGroup' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: ReservationUtilizationGroup) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ReservationUtilizationGroup -> f ReservationUtilizationGroup)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ReservationUtilizationGroup
-> f ReservationUtilizationGroup
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | How much you used this group of reservations.
reservationUtilizationGroup_utilization :: Lens.Lens' ReservationUtilizationGroup (Prelude.Maybe ReservationAggregates)
reservationUtilizationGroup_utilization :: (Maybe ReservationAggregates -> f (Maybe ReservationAggregates))
-> ReservationUtilizationGroup -> f ReservationUtilizationGroup
reservationUtilizationGroup_utilization = (ReservationUtilizationGroup -> Maybe ReservationAggregates)
-> (ReservationUtilizationGroup
    -> Maybe ReservationAggregates -> ReservationUtilizationGroup)
-> Lens
     ReservationUtilizationGroup
     ReservationUtilizationGroup
     (Maybe ReservationAggregates)
     (Maybe ReservationAggregates)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationUtilizationGroup' {Maybe ReservationAggregates
utilization :: Maybe ReservationAggregates
$sel:utilization:ReservationUtilizationGroup' :: ReservationUtilizationGroup -> Maybe ReservationAggregates
utilization} -> Maybe ReservationAggregates
utilization) (\s :: ReservationUtilizationGroup
s@ReservationUtilizationGroup' {} Maybe ReservationAggregates
a -> ReservationUtilizationGroup
s {$sel:utilization:ReservationUtilizationGroup' :: Maybe ReservationAggregates
utilization = Maybe ReservationAggregates
a} :: ReservationUtilizationGroup)

instance Core.FromJSON ReservationUtilizationGroup where
  parseJSON :: Value -> Parser ReservationUtilizationGroup
parseJSON =
    String
-> (Object -> Parser ReservationUtilizationGroup)
-> Value
-> Parser ReservationUtilizationGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReservationUtilizationGroup"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe (HashMap Text Text)
-> Maybe ReservationAggregates
-> ReservationUtilizationGroup
ReservationUtilizationGroup'
            (Maybe Text
 -> Maybe Text
 -> Maybe (HashMap Text Text)
 -> Maybe ReservationAggregates
 -> ReservationUtilizationGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe (HashMap Text Text)
      -> Maybe ReservationAggregates
      -> ReservationUtilizationGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Value")
            Parser
  (Maybe Text
   -> Maybe (HashMap Text Text)
   -> Maybe ReservationAggregates
   -> ReservationUtilizationGroup)
-> Parser (Maybe Text)
-> Parser
     (Maybe (HashMap Text Text)
      -> Maybe ReservationAggregates -> ReservationUtilizationGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Key")
            Parser
  (Maybe (HashMap Text Text)
   -> Maybe ReservationAggregates -> ReservationUtilizationGroup)
-> Parser (Maybe (HashMap Text Text))
-> Parser
     (Maybe ReservationAggregates -> ReservationUtilizationGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe (HashMap Text Text)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attributes" Parser (Maybe (Maybe (HashMap Text Text)))
-> Maybe (HashMap Text Text) -> Parser (Maybe (HashMap Text Text))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text Text)
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe ReservationAggregates -> ReservationUtilizationGroup)
-> Parser (Maybe ReservationAggregates)
-> Parser ReservationUtilizationGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ReservationAggregates)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Utilization")
      )

instance Prelude.Hashable ReservationUtilizationGroup

instance Prelude.NFData ReservationUtilizationGroup