{-# 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.GameLift.Types.MatchmakingRuleSet
-- 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.GameLift.Types.MatchmakingRuleSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Set of rule statements, used with FlexMatch, that determine how to build
-- your player matches. Each rule set describes a type of group to be
-- created and defines the parameters for acceptable player matches. Rule
-- sets are used in MatchmakingConfiguration objects.
--
-- A rule set may define the following elements for a match. For detailed
-- information and examples showing how to construct a rule set, see
-- <https://docs.aws.amazon.com/gamelift/latest/flexmatchguide/match-rulesets.html Build a FlexMatch rule set>.
--
-- -   Teams -- Required. A rule set must define one or multiple teams for
--     the match and set minimum and maximum team sizes. For example, a
--     rule set might describe a 4x4 match that requires all eight slots to
--     be filled.
--
-- -   Player attributes -- Optional. These attributes specify a set of
--     player characteristics to evaluate when looking for a match.
--     Matchmaking requests that use a rule set with player attributes must
--     provide the corresponding attribute values. For example, an
--     attribute might specify a player\'s skill or level.
--
-- -   Rules -- Optional. Rules define how to evaluate potential players
--     for a match based on player attributes. A rule might specify minimum
--     requirements for individual players, teams, or entire matches. For
--     example, a rule might require each player to meet a certain skill
--     level, each team to have at least one player in a certain role, or
--     the match to have a minimum average skill level. or may describe an
--     entire group--such as all teams must be evenly matched or have at
--     least one player in a certain role.
--
-- -   Expansions -- Optional. Expansions allow you to relax the rules
--     after a period of time when no acceptable matches are found. This
--     feature lets you balance getting players into games in a reasonable
--     amount of time instead of making them wait indefinitely for the best
--     possible match. For example, you might use an expansion to increase
--     the maximum skill variance between players after 30 seconds.
--
-- /See:/ 'newMatchmakingRuleSet' smart constructor.
data MatchmakingRuleSet = MatchmakingRuleSet'
  { -- | A time stamp indicating when this data object was created. Format is a
    -- number expressed in Unix time as milliseconds (for example
    -- @\"1469498468.057\"@).
    MatchmakingRuleSet -> Maybe POSIX
creationTime :: Prelude.Maybe Core.POSIX,
    -- | A unique identifier for the matchmaking rule set
    MatchmakingRuleSet -> Maybe Text
ruleSetName :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name
    -- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
    -- that is assigned to a GameLift matchmaking rule set resource and
    -- uniquely identifies it. ARNs are unique across all Regions. Format is
    -- @arn:aws:gamelift:\<region>::matchmakingruleset\/\<ruleset name>@. In a
    -- GameLift rule set ARN, the resource ID matches the /RuleSetName/ value.
    MatchmakingRuleSet -> Maybe Text
ruleSetArn :: Prelude.Maybe Prelude.Text,
    -- | A collection of matchmaking rules, formatted as a JSON string. Comments
    -- are not allowed in JSON, but most elements support a description field.
    MatchmakingRuleSet -> Text
ruleSetBody :: Prelude.Text
  }
  deriving (MatchmakingRuleSet -> MatchmakingRuleSet -> Bool
(MatchmakingRuleSet -> MatchmakingRuleSet -> Bool)
-> (MatchmakingRuleSet -> MatchmakingRuleSet -> Bool)
-> Eq MatchmakingRuleSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MatchmakingRuleSet -> MatchmakingRuleSet -> Bool
$c/= :: MatchmakingRuleSet -> MatchmakingRuleSet -> Bool
== :: MatchmakingRuleSet -> MatchmakingRuleSet -> Bool
$c== :: MatchmakingRuleSet -> MatchmakingRuleSet -> Bool
Prelude.Eq, ReadPrec [MatchmakingRuleSet]
ReadPrec MatchmakingRuleSet
Int -> ReadS MatchmakingRuleSet
ReadS [MatchmakingRuleSet]
(Int -> ReadS MatchmakingRuleSet)
-> ReadS [MatchmakingRuleSet]
-> ReadPrec MatchmakingRuleSet
-> ReadPrec [MatchmakingRuleSet]
-> Read MatchmakingRuleSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MatchmakingRuleSet]
$creadListPrec :: ReadPrec [MatchmakingRuleSet]
readPrec :: ReadPrec MatchmakingRuleSet
$creadPrec :: ReadPrec MatchmakingRuleSet
readList :: ReadS [MatchmakingRuleSet]
$creadList :: ReadS [MatchmakingRuleSet]
readsPrec :: Int -> ReadS MatchmakingRuleSet
$creadsPrec :: Int -> ReadS MatchmakingRuleSet
Prelude.Read, Int -> MatchmakingRuleSet -> ShowS
[MatchmakingRuleSet] -> ShowS
MatchmakingRuleSet -> String
(Int -> MatchmakingRuleSet -> ShowS)
-> (MatchmakingRuleSet -> String)
-> ([MatchmakingRuleSet] -> ShowS)
-> Show MatchmakingRuleSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MatchmakingRuleSet] -> ShowS
$cshowList :: [MatchmakingRuleSet] -> ShowS
show :: MatchmakingRuleSet -> String
$cshow :: MatchmakingRuleSet -> String
showsPrec :: Int -> MatchmakingRuleSet -> ShowS
$cshowsPrec :: Int -> MatchmakingRuleSet -> ShowS
Prelude.Show, (forall x. MatchmakingRuleSet -> Rep MatchmakingRuleSet x)
-> (forall x. Rep MatchmakingRuleSet x -> MatchmakingRuleSet)
-> Generic MatchmakingRuleSet
forall x. Rep MatchmakingRuleSet x -> MatchmakingRuleSet
forall x. MatchmakingRuleSet -> Rep MatchmakingRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MatchmakingRuleSet x -> MatchmakingRuleSet
$cfrom :: forall x. MatchmakingRuleSet -> Rep MatchmakingRuleSet x
Prelude.Generic)

-- |
-- Create a value of 'MatchmakingRuleSet' 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:
--
-- 'creationTime', 'matchmakingRuleSet_creationTime' - A time stamp indicating when this data object was created. Format is a
-- number expressed in Unix time as milliseconds (for example
-- @\"1469498468.057\"@).
--
-- 'ruleSetName', 'matchmakingRuleSet_ruleSetName' - A unique identifier for the matchmaking rule set
--
-- 'ruleSetArn', 'matchmakingRuleSet_ruleSetArn' - The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- that is assigned to a GameLift matchmaking rule set resource and
-- uniquely identifies it. ARNs are unique across all Regions. Format is
-- @arn:aws:gamelift:\<region>::matchmakingruleset\/\<ruleset name>@. In a
-- GameLift rule set ARN, the resource ID matches the /RuleSetName/ value.
--
-- 'ruleSetBody', 'matchmakingRuleSet_ruleSetBody' - A collection of matchmaking rules, formatted as a JSON string. Comments
-- are not allowed in JSON, but most elements support a description field.
newMatchmakingRuleSet ::
  -- | 'ruleSetBody'
  Prelude.Text ->
  MatchmakingRuleSet
newMatchmakingRuleSet :: Text -> MatchmakingRuleSet
newMatchmakingRuleSet Text
pRuleSetBody_ =
  MatchmakingRuleSet' :: Maybe POSIX
-> Maybe Text -> Maybe Text -> Text -> MatchmakingRuleSet
MatchmakingRuleSet'
    { $sel:creationTime:MatchmakingRuleSet' :: Maybe POSIX
creationTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleSetName:MatchmakingRuleSet' :: Maybe Text
ruleSetName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleSetArn:MatchmakingRuleSet' :: Maybe Text
ruleSetArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:ruleSetBody:MatchmakingRuleSet' :: Text
ruleSetBody = Text
pRuleSetBody_
    }

-- | A time stamp indicating when this data object was created. Format is a
-- number expressed in Unix time as milliseconds (for example
-- @\"1469498468.057\"@).
matchmakingRuleSet_creationTime :: Lens.Lens' MatchmakingRuleSet (Prelude.Maybe Prelude.UTCTime)
matchmakingRuleSet_creationTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> MatchmakingRuleSet -> f MatchmakingRuleSet
matchmakingRuleSet_creationTime = (MatchmakingRuleSet -> Maybe POSIX)
-> (MatchmakingRuleSet -> Maybe POSIX -> MatchmakingRuleSet)
-> Lens
     MatchmakingRuleSet MatchmakingRuleSet (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchmakingRuleSet' {Maybe POSIX
creationTime :: Maybe POSIX
$sel:creationTime:MatchmakingRuleSet' :: MatchmakingRuleSet -> Maybe POSIX
creationTime} -> Maybe POSIX
creationTime) (\s :: MatchmakingRuleSet
s@MatchmakingRuleSet' {} Maybe POSIX
a -> MatchmakingRuleSet
s {$sel:creationTime:MatchmakingRuleSet' :: Maybe POSIX
creationTime = Maybe POSIX
a} :: MatchmakingRuleSet) ((Maybe POSIX -> f (Maybe POSIX))
 -> MatchmakingRuleSet -> f MatchmakingRuleSet)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> MatchmakingRuleSet
-> f MatchmakingRuleSet
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

-- | A unique identifier for the matchmaking rule set
matchmakingRuleSet_ruleSetName :: Lens.Lens' MatchmakingRuleSet (Prelude.Maybe Prelude.Text)
matchmakingRuleSet_ruleSetName :: (Maybe Text -> f (Maybe Text))
-> MatchmakingRuleSet -> f MatchmakingRuleSet
matchmakingRuleSet_ruleSetName = (MatchmakingRuleSet -> Maybe Text)
-> (MatchmakingRuleSet -> Maybe Text -> MatchmakingRuleSet)
-> Lens
     MatchmakingRuleSet MatchmakingRuleSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchmakingRuleSet' {Maybe Text
ruleSetName :: Maybe Text
$sel:ruleSetName:MatchmakingRuleSet' :: MatchmakingRuleSet -> Maybe Text
ruleSetName} -> Maybe Text
ruleSetName) (\s :: MatchmakingRuleSet
s@MatchmakingRuleSet' {} Maybe Text
a -> MatchmakingRuleSet
s {$sel:ruleSetName:MatchmakingRuleSet' :: Maybe Text
ruleSetName = Maybe Text
a} :: MatchmakingRuleSet)

-- | The Amazon Resource Name
-- (<https://docs.aws.amazon.com/AmazonS3/latest/dev/s3-arn-format.html ARN>)
-- that is assigned to a GameLift matchmaking rule set resource and
-- uniquely identifies it. ARNs are unique across all Regions. Format is
-- @arn:aws:gamelift:\<region>::matchmakingruleset\/\<ruleset name>@. In a
-- GameLift rule set ARN, the resource ID matches the /RuleSetName/ value.
matchmakingRuleSet_ruleSetArn :: Lens.Lens' MatchmakingRuleSet (Prelude.Maybe Prelude.Text)
matchmakingRuleSet_ruleSetArn :: (Maybe Text -> f (Maybe Text))
-> MatchmakingRuleSet -> f MatchmakingRuleSet
matchmakingRuleSet_ruleSetArn = (MatchmakingRuleSet -> Maybe Text)
-> (MatchmakingRuleSet -> Maybe Text -> MatchmakingRuleSet)
-> Lens
     MatchmakingRuleSet MatchmakingRuleSet (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchmakingRuleSet' {Maybe Text
ruleSetArn :: Maybe Text
$sel:ruleSetArn:MatchmakingRuleSet' :: MatchmakingRuleSet -> Maybe Text
ruleSetArn} -> Maybe Text
ruleSetArn) (\s :: MatchmakingRuleSet
s@MatchmakingRuleSet' {} Maybe Text
a -> MatchmakingRuleSet
s {$sel:ruleSetArn:MatchmakingRuleSet' :: Maybe Text
ruleSetArn = Maybe Text
a} :: MatchmakingRuleSet)

-- | A collection of matchmaking rules, formatted as a JSON string. Comments
-- are not allowed in JSON, but most elements support a description field.
matchmakingRuleSet_ruleSetBody :: Lens.Lens' MatchmakingRuleSet Prelude.Text
matchmakingRuleSet_ruleSetBody :: (Text -> f Text) -> MatchmakingRuleSet -> f MatchmakingRuleSet
matchmakingRuleSet_ruleSetBody = (MatchmakingRuleSet -> Text)
-> (MatchmakingRuleSet -> Text -> MatchmakingRuleSet)
-> Lens MatchmakingRuleSet MatchmakingRuleSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MatchmakingRuleSet' {Text
ruleSetBody :: Text
$sel:ruleSetBody:MatchmakingRuleSet' :: MatchmakingRuleSet -> Text
ruleSetBody} -> Text
ruleSetBody) (\s :: MatchmakingRuleSet
s@MatchmakingRuleSet' {} Text
a -> MatchmakingRuleSet
s {$sel:ruleSetBody:MatchmakingRuleSet' :: Text
ruleSetBody = Text
a} :: MatchmakingRuleSet)

instance Core.FromJSON MatchmakingRuleSet where
  parseJSON :: Value -> Parser MatchmakingRuleSet
parseJSON =
    String
-> (Object -> Parser MatchmakingRuleSet)
-> Value
-> Parser MatchmakingRuleSet
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MatchmakingRuleSet"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Text -> Maybe Text -> Text -> MatchmakingRuleSet
MatchmakingRuleSet'
            (Maybe POSIX
 -> Maybe Text -> Maybe Text -> Text -> MatchmakingRuleSet)
-> Parser (Maybe POSIX)
-> Parser (Maybe Text -> Maybe Text -> Text -> MatchmakingRuleSet)
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
"CreationTime")
            Parser (Maybe Text -> Maybe Text -> Text -> MatchmakingRuleSet)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Text -> MatchmakingRuleSet)
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
"RuleSetName")
            Parser (Maybe Text -> Text -> MatchmakingRuleSet)
-> Parser (Maybe Text) -> Parser (Text -> MatchmakingRuleSet)
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
"RuleSetArn")
            Parser (Text -> MatchmakingRuleSet)
-> Parser Text -> Parser MatchmakingRuleSet
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RuleSetBody")
      )

instance Prelude.Hashable MatchmakingRuleSet

instance Prelude.NFData MatchmakingRuleSet