{-# 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.SamplingRule
-- 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.SamplingRule 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

-- | A sampling rule that services use to decide whether to instrument a
-- request. Rule fields can match properties of the service, or properties
-- of a request. The service can ignore rules that don\'t match its
-- properties.
--
-- /See:/ 'newSamplingRule' smart constructor.
data SamplingRule = SamplingRule'
  { -- | Matches attributes derived from the request.
    SamplingRule -> Maybe (HashMap Text Text)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text),
    -- | The ARN of the sampling rule. Specify a rule by either name or ARN, but
    -- not both.
    SamplingRule -> Maybe Text
ruleARN :: Prelude.Maybe Prelude.Text,
    -- | The name of the sampling rule. Specify a rule by either name or ARN, but
    -- not both.
    SamplingRule -> Maybe Text
ruleName :: Prelude.Maybe Prelude.Text,
    -- | Matches the ARN of the Amazon Web Services resource on which the service
    -- runs.
    SamplingRule -> Text
resourceARN :: Prelude.Text,
    -- | The priority of the sampling rule.
    SamplingRule -> Natural
priority :: Prelude.Natural,
    -- | The percentage of matching requests to instrument, after the reservoir
    -- is exhausted.
    SamplingRule -> Double
fixedRate :: Prelude.Double,
    -- | A fixed number of matching requests to instrument per second, prior to
    -- applying the fixed rate. The reservoir is not used directly by services,
    -- but applies to all services using the rule collectively.
    SamplingRule -> Natural
reservoirSize :: Prelude.Natural,
    -- | Matches the @name@ that the service uses to identify itself in segments.
    SamplingRule -> Text
serviceName :: Prelude.Text,
    -- | Matches the @origin@ that the service uses to identify its type in
    -- segments.
    SamplingRule -> Text
serviceType :: Prelude.Text,
    -- | Matches the hostname from a request URL.
    SamplingRule -> Text
host :: Prelude.Text,
    -- | Matches the HTTP method of a request.
    SamplingRule -> Text
hTTPMethod :: Prelude.Text,
    -- | Matches the path from a request URL.
    SamplingRule -> Text
uRLPath :: Prelude.Text,
    -- | The version of the sampling rule format (@1@).
    SamplingRule -> Natural
version :: Prelude.Natural
  }
  deriving (SamplingRule -> SamplingRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SamplingRule -> SamplingRule -> Bool
$c/= :: SamplingRule -> SamplingRule -> Bool
== :: SamplingRule -> SamplingRule -> Bool
$c== :: SamplingRule -> SamplingRule -> Bool
Prelude.Eq, ReadPrec [SamplingRule]
ReadPrec SamplingRule
Int -> ReadS SamplingRule
ReadS [SamplingRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SamplingRule]
$creadListPrec :: ReadPrec [SamplingRule]
readPrec :: ReadPrec SamplingRule
$creadPrec :: ReadPrec SamplingRule
readList :: ReadS [SamplingRule]
$creadList :: ReadS [SamplingRule]
readsPrec :: Int -> ReadS SamplingRule
$creadsPrec :: Int -> ReadS SamplingRule
Prelude.Read, Int -> SamplingRule -> ShowS
[SamplingRule] -> ShowS
SamplingRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SamplingRule] -> ShowS
$cshowList :: [SamplingRule] -> ShowS
show :: SamplingRule -> String
$cshow :: SamplingRule -> String
showsPrec :: Int -> SamplingRule -> ShowS
$cshowsPrec :: Int -> SamplingRule -> ShowS
Prelude.Show, forall x. Rep SamplingRule x -> SamplingRule
forall x. SamplingRule -> Rep SamplingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SamplingRule x -> SamplingRule
$cfrom :: forall x. SamplingRule -> Rep SamplingRule x
Prelude.Generic)

-- |
-- Create a value of 'SamplingRule' 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:
--
-- 'attributes', 'samplingRule_attributes' - Matches attributes derived from the request.
--
-- 'ruleARN', 'samplingRule_ruleARN' - The ARN of the sampling rule. Specify a rule by either name or ARN, but
-- not both.
--
-- 'ruleName', 'samplingRule_ruleName' - The name of the sampling rule. Specify a rule by either name or ARN, but
-- not both.
--
-- 'resourceARN', 'samplingRule_resourceARN' - Matches the ARN of the Amazon Web Services resource on which the service
-- runs.
--
-- 'priority', 'samplingRule_priority' - The priority of the sampling rule.
--
-- 'fixedRate', 'samplingRule_fixedRate' - The percentage of matching requests to instrument, after the reservoir
-- is exhausted.
--
-- 'reservoirSize', 'samplingRule_reservoirSize' - A fixed number of matching requests to instrument per second, prior to
-- applying the fixed rate. The reservoir is not used directly by services,
-- but applies to all services using the rule collectively.
--
-- 'serviceName', 'samplingRule_serviceName' - Matches the @name@ that the service uses to identify itself in segments.
--
-- 'serviceType', 'samplingRule_serviceType' - Matches the @origin@ that the service uses to identify its type in
-- segments.
--
-- 'host', 'samplingRule_host' - Matches the hostname from a request URL.
--
-- 'hTTPMethod', 'samplingRule_hTTPMethod' - Matches the HTTP method of a request.
--
-- 'uRLPath', 'samplingRule_uRLPath' - Matches the path from a request URL.
--
-- 'version', 'samplingRule_version' - The version of the sampling rule format (@1@).
newSamplingRule ::
  -- | 'resourceARN'
  Prelude.Text ->
  -- | 'priority'
  Prelude.Natural ->
  -- | 'fixedRate'
  Prelude.Double ->
  -- | 'reservoirSize'
  Prelude.Natural ->
  -- | 'serviceName'
  Prelude.Text ->
  -- | 'serviceType'
  Prelude.Text ->
  -- | 'host'
  Prelude.Text ->
  -- | 'hTTPMethod'
  Prelude.Text ->
  -- | 'uRLPath'
  Prelude.Text ->
  -- | 'version'
  Prelude.Natural ->
  SamplingRule
newSamplingRule :: Text
-> Natural
-> Double
-> Natural
-> Text
-> Text
-> Text
-> Text
-> Text
-> Natural
-> SamplingRule
newSamplingRule
  Text
pResourceARN_
  Natural
pPriority_
  Double
pFixedRate_
  Natural
pReservoirSize_
  Text
pServiceName_
  Text
pServiceType_
  Text
pHost_
  Text
pHTTPMethod_
  Text
pURLPath_
  Natural
pVersion_ =
    SamplingRule'
      { $sel:attributes:SamplingRule' :: Maybe (HashMap Text Text)
attributes = forall a. Maybe a
Prelude.Nothing,
        $sel:ruleARN:SamplingRule' :: Maybe Text
ruleARN = forall a. Maybe a
Prelude.Nothing,
        $sel:ruleName:SamplingRule' :: Maybe Text
ruleName = forall a. Maybe a
Prelude.Nothing,
        $sel:resourceARN:SamplingRule' :: Text
resourceARN = Text
pResourceARN_,
        $sel:priority:SamplingRule' :: Natural
priority = Natural
pPriority_,
        $sel:fixedRate:SamplingRule' :: Double
fixedRate = Double
pFixedRate_,
        $sel:reservoirSize:SamplingRule' :: Natural
reservoirSize = Natural
pReservoirSize_,
        $sel:serviceName:SamplingRule' :: Text
serviceName = Text
pServiceName_,
        $sel:serviceType:SamplingRule' :: Text
serviceType = Text
pServiceType_,
        $sel:host:SamplingRule' :: Text
host = Text
pHost_,
        $sel:hTTPMethod:SamplingRule' :: Text
hTTPMethod = Text
pHTTPMethod_,
        $sel:uRLPath:SamplingRule' :: Text
uRLPath = Text
pURLPath_,
        $sel:version:SamplingRule' :: Natural
version = Natural
pVersion_
      }

-- | Matches attributes derived from the request.
samplingRule_attributes :: Lens.Lens' SamplingRule (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
samplingRule_attributes :: Lens' SamplingRule (Maybe (HashMap Text Text))
samplingRule_attributes = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Maybe (HashMap Text Text)
attributes :: Maybe (HashMap Text Text)
$sel:attributes:SamplingRule' :: SamplingRule -> Maybe (HashMap Text Text)
attributes} -> Maybe (HashMap Text Text)
attributes) (\s :: SamplingRule
s@SamplingRule' {} Maybe (HashMap Text Text)
a -> SamplingRule
s {$sel:attributes:SamplingRule' :: Maybe (HashMap Text Text)
attributes = Maybe (HashMap Text Text)
a} :: SamplingRule) 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 s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The ARN of the sampling rule. Specify a rule by either name or ARN, but
-- not both.
samplingRule_ruleARN :: Lens.Lens' SamplingRule (Prelude.Maybe Prelude.Text)
samplingRule_ruleARN :: Lens' SamplingRule (Maybe Text)
samplingRule_ruleARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Maybe Text
ruleARN :: Maybe Text
$sel:ruleARN:SamplingRule' :: SamplingRule -> Maybe Text
ruleARN} -> Maybe Text
ruleARN) (\s :: SamplingRule
s@SamplingRule' {} Maybe Text
a -> SamplingRule
s {$sel:ruleARN:SamplingRule' :: Maybe Text
ruleARN = Maybe Text
a} :: SamplingRule)

-- | The name of the sampling rule. Specify a rule by either name or ARN, but
-- not both.
samplingRule_ruleName :: Lens.Lens' SamplingRule (Prelude.Maybe Prelude.Text)
samplingRule_ruleName :: Lens' SamplingRule (Maybe Text)
samplingRule_ruleName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Maybe Text
ruleName :: Maybe Text
$sel:ruleName:SamplingRule' :: SamplingRule -> Maybe Text
ruleName} -> Maybe Text
ruleName) (\s :: SamplingRule
s@SamplingRule' {} Maybe Text
a -> SamplingRule
s {$sel:ruleName:SamplingRule' :: Maybe Text
ruleName = Maybe Text
a} :: SamplingRule)

-- | Matches the ARN of the Amazon Web Services resource on which the service
-- runs.
samplingRule_resourceARN :: Lens.Lens' SamplingRule Prelude.Text
samplingRule_resourceARN :: Lens' SamplingRule Text
samplingRule_resourceARN = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Text
resourceARN :: Text
$sel:resourceARN:SamplingRule' :: SamplingRule -> Text
resourceARN} -> Text
resourceARN) (\s :: SamplingRule
s@SamplingRule' {} Text
a -> SamplingRule
s {$sel:resourceARN:SamplingRule' :: Text
resourceARN = Text
a} :: SamplingRule)

-- | The priority of the sampling rule.
samplingRule_priority :: Lens.Lens' SamplingRule Prelude.Natural
samplingRule_priority :: Lens' SamplingRule Natural
samplingRule_priority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Natural
priority :: Natural
$sel:priority:SamplingRule' :: SamplingRule -> Natural
priority} -> Natural
priority) (\s :: SamplingRule
s@SamplingRule' {} Natural
a -> SamplingRule
s {$sel:priority:SamplingRule' :: Natural
priority = Natural
a} :: SamplingRule)

-- | The percentage of matching requests to instrument, after the reservoir
-- is exhausted.
samplingRule_fixedRate :: Lens.Lens' SamplingRule Prelude.Double
samplingRule_fixedRate :: Lens' SamplingRule Double
samplingRule_fixedRate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Double
fixedRate :: Double
$sel:fixedRate:SamplingRule' :: SamplingRule -> Double
fixedRate} -> Double
fixedRate) (\s :: SamplingRule
s@SamplingRule' {} Double
a -> SamplingRule
s {$sel:fixedRate:SamplingRule' :: Double
fixedRate = Double
a} :: SamplingRule)

-- | A fixed number of matching requests to instrument per second, prior to
-- applying the fixed rate. The reservoir is not used directly by services,
-- but applies to all services using the rule collectively.
samplingRule_reservoirSize :: Lens.Lens' SamplingRule Prelude.Natural
samplingRule_reservoirSize :: Lens' SamplingRule Natural
samplingRule_reservoirSize = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Natural
reservoirSize :: Natural
$sel:reservoirSize:SamplingRule' :: SamplingRule -> Natural
reservoirSize} -> Natural
reservoirSize) (\s :: SamplingRule
s@SamplingRule' {} Natural
a -> SamplingRule
s {$sel:reservoirSize:SamplingRule' :: Natural
reservoirSize = Natural
a} :: SamplingRule)

-- | Matches the @name@ that the service uses to identify itself in segments.
samplingRule_serviceName :: Lens.Lens' SamplingRule Prelude.Text
samplingRule_serviceName :: Lens' SamplingRule Text
samplingRule_serviceName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Text
serviceName :: Text
$sel:serviceName:SamplingRule' :: SamplingRule -> Text
serviceName} -> Text
serviceName) (\s :: SamplingRule
s@SamplingRule' {} Text
a -> SamplingRule
s {$sel:serviceName:SamplingRule' :: Text
serviceName = Text
a} :: SamplingRule)

-- | Matches the @origin@ that the service uses to identify its type in
-- segments.
samplingRule_serviceType :: Lens.Lens' SamplingRule Prelude.Text
samplingRule_serviceType :: Lens' SamplingRule Text
samplingRule_serviceType = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Text
serviceType :: Text
$sel:serviceType:SamplingRule' :: SamplingRule -> Text
serviceType} -> Text
serviceType) (\s :: SamplingRule
s@SamplingRule' {} Text
a -> SamplingRule
s {$sel:serviceType:SamplingRule' :: Text
serviceType = Text
a} :: SamplingRule)

-- | Matches the hostname from a request URL.
samplingRule_host :: Lens.Lens' SamplingRule Prelude.Text
samplingRule_host :: Lens' SamplingRule Text
samplingRule_host = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Text
host :: Text
$sel:host:SamplingRule' :: SamplingRule -> Text
host} -> Text
host) (\s :: SamplingRule
s@SamplingRule' {} Text
a -> SamplingRule
s {$sel:host:SamplingRule' :: Text
host = Text
a} :: SamplingRule)

-- | Matches the HTTP method of a request.
samplingRule_hTTPMethod :: Lens.Lens' SamplingRule Prelude.Text
samplingRule_hTTPMethod :: Lens' SamplingRule Text
samplingRule_hTTPMethod = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Text
hTTPMethod :: Text
$sel:hTTPMethod:SamplingRule' :: SamplingRule -> Text
hTTPMethod} -> Text
hTTPMethod) (\s :: SamplingRule
s@SamplingRule' {} Text
a -> SamplingRule
s {$sel:hTTPMethod:SamplingRule' :: Text
hTTPMethod = Text
a} :: SamplingRule)

-- | Matches the path from a request URL.
samplingRule_uRLPath :: Lens.Lens' SamplingRule Prelude.Text
samplingRule_uRLPath :: Lens' SamplingRule Text
samplingRule_uRLPath = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Text
uRLPath :: Text
$sel:uRLPath:SamplingRule' :: SamplingRule -> Text
uRLPath} -> Text
uRLPath) (\s :: SamplingRule
s@SamplingRule' {} Text
a -> SamplingRule
s {$sel:uRLPath:SamplingRule' :: Text
uRLPath = Text
a} :: SamplingRule)

-- | The version of the sampling rule format (@1@).
samplingRule_version :: Lens.Lens' SamplingRule Prelude.Natural
samplingRule_version :: Lens' SamplingRule Natural
samplingRule_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SamplingRule' {Natural
version :: Natural
$sel:version:SamplingRule' :: SamplingRule -> Natural
version} -> Natural
version) (\s :: SamplingRule
s@SamplingRule' {} Natural
a -> SamplingRule
s {$sel:version:SamplingRule' :: Natural
version = Natural
a} :: SamplingRule)

instance Data.FromJSON SamplingRule where
  parseJSON :: Value -> Parser SamplingRule
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SamplingRule"
      ( \Object
x ->
          Maybe (HashMap Text Text)
-> Maybe Text
-> Maybe Text
-> Text
-> Natural
-> Double
-> Natural
-> Text
-> Text
-> Text
-> Text
-> Text
-> Natural
-> SamplingRule
SamplingRule'
            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
"Attributes" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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
"RuleARN")
            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
"RuleName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ResourceARN")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Priority")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"FixedRate")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ReservoirSize")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ServiceName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"ServiceType")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Host")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"HTTPMethod")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"URLPath")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Version")
      )

instance Prelude.Hashable SamplingRule where
  hashWithSalt :: Int -> SamplingRule -> Int
hashWithSalt Int
_salt SamplingRule' {Double
Natural
Maybe Text
Maybe (HashMap Text Text)
Text
version :: Natural
uRLPath :: Text
hTTPMethod :: Text
host :: Text
serviceType :: Text
serviceName :: Text
reservoirSize :: Natural
fixedRate :: Double
priority :: Natural
resourceARN :: Text
ruleName :: Maybe Text
ruleARN :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:version:SamplingRule' :: SamplingRule -> Natural
$sel:uRLPath:SamplingRule' :: SamplingRule -> Text
$sel:hTTPMethod:SamplingRule' :: SamplingRule -> Text
$sel:host:SamplingRule' :: SamplingRule -> Text
$sel:serviceType:SamplingRule' :: SamplingRule -> Text
$sel:serviceName:SamplingRule' :: SamplingRule -> Text
$sel:reservoirSize:SamplingRule' :: SamplingRule -> Natural
$sel:fixedRate:SamplingRule' :: SamplingRule -> Double
$sel:priority:SamplingRule' :: SamplingRule -> Natural
$sel:resourceARN:SamplingRule' :: SamplingRule -> Text
$sel:ruleName:SamplingRule' :: SamplingRule -> Maybe Text
$sel:ruleARN:SamplingRule' :: SamplingRule -> Maybe Text
$sel:attributes:SamplingRule' :: SamplingRule -> Maybe (HashMap Text Text)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text Text)
attributes
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceARN
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
priority
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Double
fixedRate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
reservoirSize
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serviceName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
serviceType
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
host
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hTTPMethod
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
uRLPath
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
version

instance Prelude.NFData SamplingRule where
  rnf :: SamplingRule -> ()
rnf SamplingRule' {Double
Natural
Maybe Text
Maybe (HashMap Text Text)
Text
version :: Natural
uRLPath :: Text
hTTPMethod :: Text
host :: Text
serviceType :: Text
serviceName :: Text
reservoirSize :: Natural
fixedRate :: Double
priority :: Natural
resourceARN :: Text
ruleName :: Maybe Text
ruleARN :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:version:SamplingRule' :: SamplingRule -> Natural
$sel:uRLPath:SamplingRule' :: SamplingRule -> Text
$sel:hTTPMethod:SamplingRule' :: SamplingRule -> Text
$sel:host:SamplingRule' :: SamplingRule -> Text
$sel:serviceType:SamplingRule' :: SamplingRule -> Text
$sel:serviceName:SamplingRule' :: SamplingRule -> Text
$sel:reservoirSize:SamplingRule' :: SamplingRule -> Natural
$sel:fixedRate:SamplingRule' :: SamplingRule -> Double
$sel:priority:SamplingRule' :: SamplingRule -> Natural
$sel:resourceARN:SamplingRule' :: SamplingRule -> Text
$sel:ruleName:SamplingRule' :: SamplingRule -> Maybe Text
$sel:ruleARN:SamplingRule' :: SamplingRule -> Maybe Text
$sel:attributes:SamplingRule' :: SamplingRule -> Maybe (HashMap Text Text)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text Text)
attributes
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceARN
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
priority
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Double
fixedRate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
reservoirSize
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serviceName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
serviceType
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
host
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
hTTPMethod
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
uRLPath
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
version

instance Data.ToJSON SamplingRule where
  toJSON :: SamplingRule -> Value
toJSON SamplingRule' {Double
Natural
Maybe Text
Maybe (HashMap Text Text)
Text
version :: Natural
uRLPath :: Text
hTTPMethod :: Text
host :: Text
serviceType :: Text
serviceName :: Text
reservoirSize :: Natural
fixedRate :: Double
priority :: Natural
resourceARN :: Text
ruleName :: Maybe Text
ruleARN :: Maybe Text
attributes :: Maybe (HashMap Text Text)
$sel:version:SamplingRule' :: SamplingRule -> Natural
$sel:uRLPath:SamplingRule' :: SamplingRule -> Text
$sel:hTTPMethod:SamplingRule' :: SamplingRule -> Text
$sel:host:SamplingRule' :: SamplingRule -> Text
$sel:serviceType:SamplingRule' :: SamplingRule -> Text
$sel:serviceName:SamplingRule' :: SamplingRule -> Text
$sel:reservoirSize:SamplingRule' :: SamplingRule -> Natural
$sel:fixedRate:SamplingRule' :: SamplingRule -> Double
$sel:priority:SamplingRule' :: SamplingRule -> Natural
$sel:resourceARN:SamplingRule' :: SamplingRule -> Text
$sel:ruleName:SamplingRule' :: SamplingRule -> Maybe Text
$sel:ruleARN:SamplingRule' :: SamplingRule -> Maybe Text
$sel:attributes:SamplingRule' :: SamplingRule -> Maybe (HashMap Text Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Attributes" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
attributes,
            (Key
"RuleARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleARN,
            (Key
"RuleName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
ruleName,
            forall a. a -> Maybe a
Prelude.Just (Key
"ResourceARN" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceARN),
            forall a. a -> Maybe a
Prelude.Just (Key
"Priority" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
priority),
            forall a. a -> Maybe a
Prelude.Just (Key
"FixedRate" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Double
fixedRate),
            forall a. a -> Maybe a
Prelude.Just (Key
"ReservoirSize" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
reservoirSize),
            forall a. a -> Maybe a
Prelude.Just (Key
"ServiceName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
serviceName),
            forall a. a -> Maybe a
Prelude.Just (Key
"ServiceType" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
serviceType),
            forall a. a -> Maybe a
Prelude.Just (Key
"Host" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
host),
            forall a. a -> Maybe a
Prelude.Just (Key
"HTTPMethod" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hTTPMethod),
            forall a. a -> Maybe a
Prelude.Just (Key
"URLPath" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
uRLPath),
            forall a. a -> Maybe a
Prelude.Just (Key
"Version" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
version)
          ]
      )