{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.XRay.Types.SamplingRuleRecord where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 created.
    SamplingRuleRecord -> Maybe POSIX
createdAt :: Prelude.Maybe Data.POSIX,
    -- | When the rule was last modified.
    SamplingRuleRecord -> Maybe POSIX
modifiedAt :: Prelude.Maybe Data.POSIX,
    -- | The sampling rule.
    SamplingRuleRecord -> Maybe SamplingRule
samplingRule :: Prelude.Maybe SamplingRule
  }
  deriving (SamplingRuleRecord -> SamplingRuleRecord -> Bool
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]
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
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. 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:
--
-- 'createdAt', 'samplingRuleRecord_createdAt' - When the rule was created.
--
-- 'modifiedAt', 'samplingRuleRecord_modifiedAt' - When the rule was last modified.
--
-- 'samplingRule', 'samplingRuleRecord_samplingRule' - The sampling rule.
newSamplingRuleRecord ::
  SamplingRuleRecord
newSamplingRuleRecord :: SamplingRuleRecord
newSamplingRuleRecord =
  SamplingRuleRecord'
    { $sel:createdAt:SamplingRuleRecord' :: Maybe POSIX
createdAt = forall a. Maybe a
Prelude.Nothing,
      $sel:modifiedAt:SamplingRuleRecord' :: Maybe POSIX
modifiedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:samplingRule:SamplingRuleRecord' :: Maybe SamplingRule
samplingRule = forall a. Maybe a
Prelude.Nothing
    }

-- | When the rule was created.
samplingRuleRecord_createdAt :: Lens.Lens' SamplingRuleRecord (Prelude.Maybe Prelude.UTCTime)
samplingRuleRecord_createdAt :: Lens' SamplingRuleRecord (Maybe UTCTime)
samplingRuleRecord_createdAt = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | When the rule was last modified.
samplingRuleRecord_modifiedAt :: Lens.Lens' SamplingRuleRecord (Prelude.Maybe Prelude.UTCTime)
samplingRuleRecord_modifiedAt :: Lens' SamplingRuleRecord (Maybe UTCTime)
samplingRuleRecord_modifiedAt = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | The sampling rule.
samplingRuleRecord_samplingRule :: Lens.Lens' SamplingRuleRecord (Prelude.Maybe SamplingRule)
samplingRuleRecord_samplingRule :: Lens' SamplingRuleRecord (Maybe SamplingRule)
samplingRuleRecord_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)

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

instance Prelude.Hashable SamplingRuleRecord where
  hashWithSalt :: Int -> SamplingRuleRecord -> Int
hashWithSalt Int
_salt SamplingRuleRecord' {Maybe POSIX
Maybe SamplingRule
samplingRule :: Maybe SamplingRule
modifiedAt :: Maybe POSIX
createdAt :: Maybe POSIX
$sel:samplingRule:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe SamplingRule
$sel:modifiedAt:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe POSIX
$sel:createdAt:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe POSIX
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
createdAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe POSIX
modifiedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SamplingRule
samplingRule

instance Prelude.NFData SamplingRuleRecord where
  rnf :: SamplingRuleRecord -> ()
rnf SamplingRuleRecord' {Maybe POSIX
Maybe SamplingRule
samplingRule :: Maybe SamplingRule
modifiedAt :: Maybe POSIX
createdAt :: Maybe POSIX
$sel:samplingRule:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe SamplingRule
$sel:modifiedAt:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe POSIX
$sel:createdAt:SamplingRuleRecord' :: SamplingRuleRecord -> Maybe POSIX
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
createdAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe POSIX
modifiedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe SamplingRule
samplingRule