{-# 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.SecurityHub.Types.AwsEcsServicePlacementConstraintsDetails
-- 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.SecurityHub.Types.AwsEcsServicePlacementConstraintsDetails where

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

-- | A placement constraint for the tasks in the service.
--
-- /See:/ 'newAwsEcsServicePlacementConstraintsDetails' smart constructor.
data AwsEcsServicePlacementConstraintsDetails = AwsEcsServicePlacementConstraintsDetails'
  { -- | A cluster query language expression to apply to the constraint. You
    -- cannot specify an expression if the constraint type is
    -- @distinctInstance@.
    AwsEcsServicePlacementConstraintsDetails -> Maybe Text
expression :: Prelude.Maybe Prelude.Text,
    -- | The type of constraint. Use @distinctInstance@ to run each task in a
    -- particular group on a different container instance. Use @memberOf@ to
    -- restrict the selection to a group of valid candidates.
    --
    -- Valid values: @distinctInstance@ | @memberOf@
    AwsEcsServicePlacementConstraintsDetails -> Maybe Text
type' :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsEcsServicePlacementConstraintsDetails
-> AwsEcsServicePlacementConstraintsDetails -> Bool
(AwsEcsServicePlacementConstraintsDetails
 -> AwsEcsServicePlacementConstraintsDetails -> Bool)
-> (AwsEcsServicePlacementConstraintsDetails
    -> AwsEcsServicePlacementConstraintsDetails -> Bool)
-> Eq AwsEcsServicePlacementConstraintsDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsEcsServicePlacementConstraintsDetails
-> AwsEcsServicePlacementConstraintsDetails -> Bool
$c/= :: AwsEcsServicePlacementConstraintsDetails
-> AwsEcsServicePlacementConstraintsDetails -> Bool
== :: AwsEcsServicePlacementConstraintsDetails
-> AwsEcsServicePlacementConstraintsDetails -> Bool
$c== :: AwsEcsServicePlacementConstraintsDetails
-> AwsEcsServicePlacementConstraintsDetails -> Bool
Prelude.Eq, ReadPrec [AwsEcsServicePlacementConstraintsDetails]
ReadPrec AwsEcsServicePlacementConstraintsDetails
Int -> ReadS AwsEcsServicePlacementConstraintsDetails
ReadS [AwsEcsServicePlacementConstraintsDetails]
(Int -> ReadS AwsEcsServicePlacementConstraintsDetails)
-> ReadS [AwsEcsServicePlacementConstraintsDetails]
-> ReadPrec AwsEcsServicePlacementConstraintsDetails
-> ReadPrec [AwsEcsServicePlacementConstraintsDetails]
-> Read AwsEcsServicePlacementConstraintsDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsEcsServicePlacementConstraintsDetails]
$creadListPrec :: ReadPrec [AwsEcsServicePlacementConstraintsDetails]
readPrec :: ReadPrec AwsEcsServicePlacementConstraintsDetails
$creadPrec :: ReadPrec AwsEcsServicePlacementConstraintsDetails
readList :: ReadS [AwsEcsServicePlacementConstraintsDetails]
$creadList :: ReadS [AwsEcsServicePlacementConstraintsDetails]
readsPrec :: Int -> ReadS AwsEcsServicePlacementConstraintsDetails
$creadsPrec :: Int -> ReadS AwsEcsServicePlacementConstraintsDetails
Prelude.Read, Int -> AwsEcsServicePlacementConstraintsDetails -> ShowS
[AwsEcsServicePlacementConstraintsDetails] -> ShowS
AwsEcsServicePlacementConstraintsDetails -> String
(Int -> AwsEcsServicePlacementConstraintsDetails -> ShowS)
-> (AwsEcsServicePlacementConstraintsDetails -> String)
-> ([AwsEcsServicePlacementConstraintsDetails] -> ShowS)
-> Show AwsEcsServicePlacementConstraintsDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsEcsServicePlacementConstraintsDetails] -> ShowS
$cshowList :: [AwsEcsServicePlacementConstraintsDetails] -> ShowS
show :: AwsEcsServicePlacementConstraintsDetails -> String
$cshow :: AwsEcsServicePlacementConstraintsDetails -> String
showsPrec :: Int -> AwsEcsServicePlacementConstraintsDetails -> ShowS
$cshowsPrec :: Int -> AwsEcsServicePlacementConstraintsDetails -> ShowS
Prelude.Show, (forall x.
 AwsEcsServicePlacementConstraintsDetails
 -> Rep AwsEcsServicePlacementConstraintsDetails x)
-> (forall x.
    Rep AwsEcsServicePlacementConstraintsDetails x
    -> AwsEcsServicePlacementConstraintsDetails)
-> Generic AwsEcsServicePlacementConstraintsDetails
forall x.
Rep AwsEcsServicePlacementConstraintsDetails x
-> AwsEcsServicePlacementConstraintsDetails
forall x.
AwsEcsServicePlacementConstraintsDetails
-> Rep AwsEcsServicePlacementConstraintsDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AwsEcsServicePlacementConstraintsDetails x
-> AwsEcsServicePlacementConstraintsDetails
$cfrom :: forall x.
AwsEcsServicePlacementConstraintsDetails
-> Rep AwsEcsServicePlacementConstraintsDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsEcsServicePlacementConstraintsDetails' 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:
--
-- 'expression', 'awsEcsServicePlacementConstraintsDetails_expression' - A cluster query language expression to apply to the constraint. You
-- cannot specify an expression if the constraint type is
-- @distinctInstance@.
--
-- 'type'', 'awsEcsServicePlacementConstraintsDetails_type' - The type of constraint. Use @distinctInstance@ to run each task in a
-- particular group on a different container instance. Use @memberOf@ to
-- restrict the selection to a group of valid candidates.
--
-- Valid values: @distinctInstance@ | @memberOf@
newAwsEcsServicePlacementConstraintsDetails ::
  AwsEcsServicePlacementConstraintsDetails
newAwsEcsServicePlacementConstraintsDetails :: AwsEcsServicePlacementConstraintsDetails
newAwsEcsServicePlacementConstraintsDetails =
  AwsEcsServicePlacementConstraintsDetails' :: Maybe Text
-> Maybe Text -> AwsEcsServicePlacementConstraintsDetails
AwsEcsServicePlacementConstraintsDetails'
    { $sel:expression:AwsEcsServicePlacementConstraintsDetails' :: Maybe Text
expression =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':AwsEcsServicePlacementConstraintsDetails' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A cluster query language expression to apply to the constraint. You
-- cannot specify an expression if the constraint type is
-- @distinctInstance@.
awsEcsServicePlacementConstraintsDetails_expression :: Lens.Lens' AwsEcsServicePlacementConstraintsDetails (Prelude.Maybe Prelude.Text)
awsEcsServicePlacementConstraintsDetails_expression :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServicePlacementConstraintsDetails
-> f AwsEcsServicePlacementConstraintsDetails
awsEcsServicePlacementConstraintsDetails_expression = (AwsEcsServicePlacementConstraintsDetails -> Maybe Text)
-> (AwsEcsServicePlacementConstraintsDetails
    -> Maybe Text -> AwsEcsServicePlacementConstraintsDetails)
-> Lens
     AwsEcsServicePlacementConstraintsDetails
     AwsEcsServicePlacementConstraintsDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServicePlacementConstraintsDetails' {Maybe Text
expression :: Maybe Text
$sel:expression:AwsEcsServicePlacementConstraintsDetails' :: AwsEcsServicePlacementConstraintsDetails -> Maybe Text
expression} -> Maybe Text
expression) (\s :: AwsEcsServicePlacementConstraintsDetails
s@AwsEcsServicePlacementConstraintsDetails' {} Maybe Text
a -> AwsEcsServicePlacementConstraintsDetails
s {$sel:expression:AwsEcsServicePlacementConstraintsDetails' :: Maybe Text
expression = Maybe Text
a} :: AwsEcsServicePlacementConstraintsDetails)

-- | The type of constraint. Use @distinctInstance@ to run each task in a
-- particular group on a different container instance. Use @memberOf@ to
-- restrict the selection to a group of valid candidates.
--
-- Valid values: @distinctInstance@ | @memberOf@
awsEcsServicePlacementConstraintsDetails_type :: Lens.Lens' AwsEcsServicePlacementConstraintsDetails (Prelude.Maybe Prelude.Text)
awsEcsServicePlacementConstraintsDetails_type :: (Maybe Text -> f (Maybe Text))
-> AwsEcsServicePlacementConstraintsDetails
-> f AwsEcsServicePlacementConstraintsDetails
awsEcsServicePlacementConstraintsDetails_type = (AwsEcsServicePlacementConstraintsDetails -> Maybe Text)
-> (AwsEcsServicePlacementConstraintsDetails
    -> Maybe Text -> AwsEcsServicePlacementConstraintsDetails)
-> Lens
     AwsEcsServicePlacementConstraintsDetails
     AwsEcsServicePlacementConstraintsDetails
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsEcsServicePlacementConstraintsDetails' {Maybe Text
type' :: Maybe Text
$sel:type':AwsEcsServicePlacementConstraintsDetails' :: AwsEcsServicePlacementConstraintsDetails -> Maybe Text
type'} -> Maybe Text
type') (\s :: AwsEcsServicePlacementConstraintsDetails
s@AwsEcsServicePlacementConstraintsDetails' {} Maybe Text
a -> AwsEcsServicePlacementConstraintsDetails
s {$sel:type':AwsEcsServicePlacementConstraintsDetails' :: Maybe Text
type' = Maybe Text
a} :: AwsEcsServicePlacementConstraintsDetails)

instance
  Core.FromJSON
    AwsEcsServicePlacementConstraintsDetails
  where
  parseJSON :: Value -> Parser AwsEcsServicePlacementConstraintsDetails
parseJSON =
    String
-> (Object -> Parser AwsEcsServicePlacementConstraintsDetails)
-> Value
-> Parser AwsEcsServicePlacementConstraintsDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsEcsServicePlacementConstraintsDetails"
      ( \Object
x ->
          Maybe Text
-> Maybe Text -> AwsEcsServicePlacementConstraintsDetails
AwsEcsServicePlacementConstraintsDetails'
            (Maybe Text
 -> Maybe Text -> AwsEcsServicePlacementConstraintsDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsEcsServicePlacementConstraintsDetails)
forall (f :: * -> *) a b. Functor 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
"Expression")
            Parser (Maybe Text -> AwsEcsServicePlacementConstraintsDetails)
-> Parser (Maybe Text)
-> Parser AwsEcsServicePlacementConstraintsDetails
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
"Type")
      )

instance
  Prelude.Hashable
    AwsEcsServicePlacementConstraintsDetails

instance
  Prelude.NFData
    AwsEcsServicePlacementConstraintsDetails

instance
  Core.ToJSON
    AwsEcsServicePlacementConstraintsDetails
  where
  toJSON :: AwsEcsServicePlacementConstraintsDetails -> Value
toJSON AwsEcsServicePlacementConstraintsDetails' {Maybe Text
type' :: Maybe Text
expression :: Maybe Text
$sel:type':AwsEcsServicePlacementConstraintsDetails' :: AwsEcsServicePlacementConstraintsDetails -> Maybe Text
$sel:expression:AwsEcsServicePlacementConstraintsDetails' :: AwsEcsServicePlacementConstraintsDetails -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Expression" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
expression,
            (Text
"Type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
type'
          ]
      )