{-# 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.XRay.Types.SamplingRuleRecord
-- 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.XRay.Types.SamplingRuleRecord where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.XRay.Types.SamplingRule

-- | A
-- <https://docs.aws.amazon.com/xray/latest/api/API_SamplingRule.html SamplingRule>
-- and its metadata.
--
-- /See:/ 'newSamplingRuleRecord' smart constructor.
data SamplingRuleRecord = SamplingRuleRecord'
  { -- | When the rule was last modified.
    SamplingRuleRecord -> Maybe POSIX
modifiedAt :: Prelude.Maybe Core.POSIX,
    -- | The sampling rule.
    SamplingRuleRecord -> Maybe SamplingRule
samplingRule :: Prelude.Maybe SamplingRule,
    -- | When the rule was created.
    SamplingRuleRecord -> Maybe POSIX
createdAt :: Prelude.Maybe Core.POSIX
  }
  deriving (SamplingRuleRecord -> SamplingRuleRecord -> Bool
(SamplingRuleRecord -> SamplingRuleRecord -> Bool)
-> (SamplingRuleRecord -> SamplingRuleRecord -> Bool)
-> Eq SamplingRuleRecord
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamplingRuleRecord -> SamplingRuleRecord -> Bool
$c/= :: SamplingRuleRecord -> SamplingRuleRecord -> Bool
== :: SamplingRuleRecord -> SamplingRuleRecord -> Bool
$c== :: SamplingRuleRecord -> SamplingRuleRecord -> Bool
Prelude.Eq, ReadPrec [SamplingRuleRecord]
ReadPrec SamplingRuleRecord
Int -> ReadS SamplingRuleRecord
ReadS [SamplingRuleRecord]
(Int -> ReadS SamplingRuleRecord)
-> ReadS [SamplingRuleRecord]
-> ReadPrec SamplingRuleRecord
-> ReadPrec [SamplingRuleRecord]
-> Read SamplingRuleRecord
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamplingRuleRecord]
$creadListPrec :: ReadPrec [SamplingRuleRecord]
readPrec :: ReadPrec SamplingRuleRecord
$creadPrec :: ReadPrec SamplingRuleRecord
readList :: ReadS [SamplingRuleRecord]
$creadList :: ReadS [SamplingRuleRecord]
readsPrec :: Int -> ReadS SamplingRuleRecord
$creadsPrec :: Int -> ReadS SamplingRuleRecord
Prelude.Read, Int -> SamplingRuleRecord -> ShowS
[SamplingRuleRecord] -> ShowS
SamplingRuleRecord -> String
(Int -> SamplingRuleRecord -> ShowS)
-> (SamplingRuleRecord -> String)
-> ([SamplingRuleRecord] -> ShowS)
-> Show SamplingRuleRecord
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamplingRuleRecord] -> ShowS
$cshowList :: [SamplingRuleRecord] -> ShowS
show :: SamplingRuleRecord -> String
$cshow :: SamplingRuleRecord -> String
showsPrec :: Int -> SamplingRuleRecord -> ShowS
$cshowsPrec :: Int -> SamplingRuleRecord -> ShowS
Prelude.Show, (forall x. SamplingRuleRecord -> Rep SamplingRuleRecord x)
-> (forall x. Rep SamplingRuleRecord x -> SamplingRuleRecord)
-> Generic SamplingRuleRecord
forall x. Rep SamplingRuleRecord x -> SamplingRuleRecord
forall x. SamplingRuleRecord -> Rep SamplingRuleRecord x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SamplingRuleRecord x -> SamplingRuleRecord
$cfrom :: forall x. SamplingRuleRecord -> Rep SamplingRuleRecord x
Prelude.Generic)

-- |
-- Create a value of 'SamplingRuleRecord' 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:
--
-- 'modifiedAt', 'samplingRuleRecord_modifiedAt' - When the rule was last modified.
--
-- 'samplingRule', 'samplingRuleRecord_samplingRule' - The sampling rule.
--
-- 'createdAt', 'samplingRuleRecord_createdAt' - When the rule was created.
newSamplingRuleRecord ::
  SamplingRuleRecord
newSamplingRuleRecord :: SamplingRuleRecord
newSamplingRuleRecord =
  SamplingRuleRecord' :: Maybe POSIX
-> Maybe SamplingRule -> Maybe POSIX -> SamplingRuleRecord
SamplingRuleRecord'
    { $sel:modifiedAt:SamplingRuleRecord' :: Maybe POSIX
modifiedAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:samplingRule:SamplingRuleRecord' :: Maybe SamplingRule
samplingRule = Maybe SamplingRule
forall a. Maybe a
Prelude.Nothing,
      $sel:createdAt:SamplingRuleRecord' :: Maybe POSIX
createdAt = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | When the rule was last modified.
samplingRuleRecord_modifiedAt :: Lens.Lens' SamplingRuleRecord (Prelude.Maybe Prelude.UTCTime)
samplingRuleRecord_modifiedAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SamplingRuleRecord -> f SamplingRuleRecord
samplingRuleRecord_modifiedAt = (SamplingRuleRecord -> Maybe POSIX)
-> (SamplingRuleRecord -> Maybe POSIX -> SamplingRuleRecord)
-> Lens
     SamplingRuleRecord SamplingRuleRecord (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRuleRecord' {Maybe POSIX
modifiedAt :: Maybe POSIX
$sel:modifiedAt:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe POSIX
modifiedAt} -> Maybe POSIX
modifiedAt) (\s :: SamplingRuleRecord
s@SamplingRuleRecord' {} Maybe POSIX
a -> SamplingRuleRecord
s {$sel:modifiedAt:SamplingRuleRecord' :: Maybe POSIX
modifiedAt = Maybe POSIX
a} :: SamplingRuleRecord) ((Maybe POSIX -> f (Maybe POSIX))
 -> SamplingRuleRecord -> f SamplingRuleRecord)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SamplingRuleRecord
-> f SamplingRuleRecord
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The sampling rule.
samplingRuleRecord_samplingRule :: Lens.Lens' SamplingRuleRecord (Prelude.Maybe SamplingRule)
samplingRuleRecord_samplingRule :: (Maybe SamplingRule -> f (Maybe SamplingRule))
-> SamplingRuleRecord -> f SamplingRuleRecord
samplingRuleRecord_samplingRule = (SamplingRuleRecord -> Maybe SamplingRule)
-> (SamplingRuleRecord -> Maybe SamplingRule -> SamplingRuleRecord)
-> Lens
     SamplingRuleRecord
     SamplingRuleRecord
     (Maybe SamplingRule)
     (Maybe SamplingRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRuleRecord' {Maybe SamplingRule
samplingRule :: Maybe SamplingRule
$sel:samplingRule:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe SamplingRule
samplingRule} -> Maybe SamplingRule
samplingRule) (\s :: SamplingRuleRecord
s@SamplingRuleRecord' {} Maybe SamplingRule
a -> SamplingRuleRecord
s {$sel:samplingRule:SamplingRuleRecord' :: Maybe SamplingRule
samplingRule = Maybe SamplingRule
a} :: SamplingRuleRecord)

-- | When the rule was created.
samplingRuleRecord_createdAt :: Lens.Lens' SamplingRuleRecord (Prelude.Maybe Prelude.UTCTime)
samplingRuleRecord_createdAt :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SamplingRuleRecord -> f SamplingRuleRecord
samplingRuleRecord_createdAt = (SamplingRuleRecord -> Maybe POSIX)
-> (SamplingRuleRecord -> Maybe POSIX -> SamplingRuleRecord)
-> Lens
     SamplingRuleRecord SamplingRuleRecord (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRuleRecord' {Maybe POSIX
createdAt :: Maybe POSIX
$sel:createdAt:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe POSIX
createdAt} -> Maybe POSIX
createdAt) (\s :: SamplingRuleRecord
s@SamplingRuleRecord' {} Maybe POSIX
a -> SamplingRuleRecord
s {$sel:createdAt:SamplingRuleRecord' :: Maybe POSIX
createdAt = Maybe POSIX
a} :: SamplingRuleRecord) ((Maybe POSIX -> f (Maybe POSIX))
 -> SamplingRuleRecord -> f SamplingRuleRecord)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SamplingRuleRecord
-> f SamplingRuleRecord
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON SamplingRuleRecord where
  parseJSON :: Value -> Parser SamplingRuleRecord
parseJSON =
    String
-> (Object -> Parser SamplingRuleRecord)
-> Value
-> Parser SamplingRuleRecord
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SamplingRuleRecord"
      ( \Object
x ->
          Maybe POSIX
-> Maybe SamplingRule -> Maybe POSIX -> SamplingRuleRecord
SamplingRuleRecord'
            (Maybe POSIX
 -> Maybe SamplingRule -> Maybe POSIX -> SamplingRuleRecord)
-> Parser (Maybe POSIX)
-> Parser (Maybe SamplingRule -> Maybe POSIX -> SamplingRuleRecord)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ModifiedAt")
            Parser (Maybe SamplingRule -> Maybe POSIX -> SamplingRuleRecord)
-> Parser (Maybe SamplingRule)
-> Parser (Maybe POSIX -> SamplingRuleRecord)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SamplingRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SamplingRule")
            Parser (Maybe POSIX -> SamplingRuleRecord)
-> Parser (Maybe POSIX) -> Parser SamplingRuleRecord
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"CreatedAt")
      )

instance Prelude.Hashable SamplingRuleRecord

instance Prelude.NFData SamplingRuleRecord