{-# 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.ReservationCoverageGroup
-- 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.ReservationCoverageGroup where

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

-- | A group of reservations that share a set of attributes.
--
-- /See:/ 'newReservationCoverageGroup' smart constructor.
data ReservationCoverageGroup = ReservationCoverageGroup'
  { -- | How much instance usage this group of reservations covered.
    ReservationCoverageGroup -> Maybe Coverage
coverage :: Prelude.Maybe Coverage,
    -- | The attributes for this group of reservations.
    ReservationCoverageGroup -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (ReservationCoverageGroup -> ReservationCoverageGroup -> Bool
(ReservationCoverageGroup -> ReservationCoverageGroup -> Bool)
-> (ReservationCoverageGroup -> ReservationCoverageGroup -> Bool)
-> Eq ReservationCoverageGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReservationCoverageGroup -> ReservationCoverageGroup -> Bool
$c/= :: ReservationCoverageGroup -> ReservationCoverageGroup -> Bool
== :: ReservationCoverageGroup -> ReservationCoverageGroup -> Bool
$c== :: ReservationCoverageGroup -> ReservationCoverageGroup -> Bool
Prelude.Eq, ReadPrec [ReservationCoverageGroup]
ReadPrec ReservationCoverageGroup
Int -> ReadS ReservationCoverageGroup
ReadS [ReservationCoverageGroup]
(Int -> ReadS ReservationCoverageGroup)
-> ReadS [ReservationCoverageGroup]
-> ReadPrec ReservationCoverageGroup
-> ReadPrec [ReservationCoverageGroup]
-> Read ReservationCoverageGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ReservationCoverageGroup]
$creadListPrec :: ReadPrec [ReservationCoverageGroup]
readPrec :: ReadPrec ReservationCoverageGroup
$creadPrec :: ReadPrec ReservationCoverageGroup
readList :: ReadS [ReservationCoverageGroup]
$creadList :: ReadS [ReservationCoverageGroup]
readsPrec :: Int -> ReadS ReservationCoverageGroup
$creadsPrec :: Int -> ReadS ReservationCoverageGroup
Prelude.Read, Int -> ReservationCoverageGroup -> ShowS
[ReservationCoverageGroup] -> ShowS
ReservationCoverageGroup -> String
(Int -> ReservationCoverageGroup -> ShowS)
-> (ReservationCoverageGroup -> String)
-> ([ReservationCoverageGroup] -> ShowS)
-> Show ReservationCoverageGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReservationCoverageGroup] -> ShowS
$cshowList :: [ReservationCoverageGroup] -> ShowS
show :: ReservationCoverageGroup -> String
$cshow :: ReservationCoverageGroup -> String
showsPrec :: Int -> ReservationCoverageGroup -> ShowS
$cshowsPrec :: Int -> ReservationCoverageGroup -> ShowS
Prelude.Show, (forall x.
 ReservationCoverageGroup -> Rep ReservationCoverageGroup x)
-> (forall x.
    Rep ReservationCoverageGroup x -> ReservationCoverageGroup)
-> Generic ReservationCoverageGroup
forall x.
Rep ReservationCoverageGroup x -> ReservationCoverageGroup
forall x.
ReservationCoverageGroup -> Rep ReservationCoverageGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ReservationCoverageGroup x -> ReservationCoverageGroup
$cfrom :: forall x.
ReservationCoverageGroup -> Rep ReservationCoverageGroup x
Prelude.Generic)

-- |
-- Create a value of 'ReservationCoverageGroup' 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:
--
-- 'coverage', 'reservationCoverageGroup_coverage' - How much instance usage this group of reservations covered.
--
-- 'attributes', 'reservationCoverageGroup_attributes' - The attributes for this group of reservations.
newReservationCoverageGroup ::
  ReservationCoverageGroup
newReservationCoverageGroup :: ReservationCoverageGroup
newReservationCoverageGroup =
  ReservationCoverageGroup' :: Maybe Coverage
-> Maybe (HashMap Text Text) -> ReservationCoverageGroup
ReservationCoverageGroup'
    { $sel:coverage:ReservationCoverageGroup' :: Maybe Coverage
coverage =
        Maybe Coverage
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:ReservationCoverageGroup' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | How much instance usage this group of reservations covered.
reservationCoverageGroup_coverage :: Lens.Lens' ReservationCoverageGroup (Prelude.Maybe Coverage)
reservationCoverageGroup_coverage :: (Maybe Coverage -> f (Maybe Coverage))
-> ReservationCoverageGroup -> f ReservationCoverageGroup
reservationCoverageGroup_coverage = (ReservationCoverageGroup -> Maybe Coverage)
-> (ReservationCoverageGroup
    -> Maybe Coverage -> ReservationCoverageGroup)
-> Lens
     ReservationCoverageGroup
     ReservationCoverageGroup
     (Maybe Coverage)
     (Maybe Coverage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ReservationCoverageGroup' {Maybe Coverage
coverage :: Maybe Coverage
$sel:coverage:ReservationCoverageGroup' :: ReservationCoverageGroup -> Maybe Coverage
coverage} -> Maybe Coverage
coverage) (\s :: ReservationCoverageGroup
s@ReservationCoverageGroup' {} Maybe Coverage
a -> ReservationCoverageGroup
s {$sel:coverage:ReservationCoverageGroup' :: Maybe Coverage
coverage = Maybe Coverage
a} :: ReservationCoverageGroup)

-- | The attributes for this group of reservations.
reservationCoverageGroup_attributes :: Lens.Lens' ReservationCoverageGroup (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
reservationCoverageGroup_attributes :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> ReservationCoverageGroup -> f ReservationCoverageGroup
reservationCoverageGroup_attributes = (ReservationCoverageGroup -> Maybe (HashMap Text Text))
-> (ReservationCoverageGroup
    -> Maybe (HashMap Text Text) -> ReservationCoverageGroup)
-> Lens
     ReservationCoverageGroup
     ReservationCoverageGroup
     (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 (\ReservationCoverageGroup' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:ReservationCoverageGroup' :: ReservationCoverageGroup -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: ReservationCoverageGroup
s@ReservationCoverageGroup' {} Maybe (HashMap Text Text)
a -> ReservationCoverageGroup
s {$sel:attributes:ReservationCoverageGroup' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: ReservationCoverageGroup) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> ReservationCoverageGroup -> f ReservationCoverageGroup)
-> ((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)))
-> ReservationCoverageGroup
-> f ReservationCoverageGroup
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

instance Core.FromJSON ReservationCoverageGroup where
  parseJSON :: Value -> Parser ReservationCoverageGroup
parseJSON =
    String
-> (Object -> Parser ReservationCoverageGroup)
-> Value
-> Parser ReservationCoverageGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ReservationCoverageGroup"
      ( \Object
x ->
          Maybe Coverage
-> Maybe (HashMap Text Text) -> ReservationCoverageGroup
ReservationCoverageGroup'
            (Maybe Coverage
 -> Maybe (HashMap Text Text) -> ReservationCoverageGroup)
-> Parser (Maybe Coverage)
-> Parser (Maybe (HashMap Text Text) -> ReservationCoverageGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Coverage)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Coverage")
            Parser (Maybe (HashMap Text Text) -> ReservationCoverageGroup)
-> Parser (Maybe (HashMap Text Text))
-> Parser ReservationCoverageGroup
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)
      )

instance Prelude.Hashable ReservationCoverageGroup

instance Prelude.NFData ReservationCoverageGroup