{-# 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.CloudDirectory.Types.ObjectAttributeRange
-- 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.CloudDirectory.Types.ObjectAttributeRange where

import Amazonka.CloudDirectory.Types.AttributeKey
import Amazonka.CloudDirectory.Types.TypedAttributeValueRange
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A range of attributes.
--
-- /See:/ 'newObjectAttributeRange' smart constructor.
data ObjectAttributeRange = ObjectAttributeRange'
  { -- | The range of attribute values being selected.
    ObjectAttributeRange -> Maybe TypedAttributeValueRange
range :: Prelude.Maybe TypedAttributeValueRange,
    -- | The key of the attribute that the attribute range covers.
    ObjectAttributeRange -> Maybe AttributeKey
attributeKey :: Prelude.Maybe AttributeKey
  }
  deriving (ObjectAttributeRange -> ObjectAttributeRange -> Bool
(ObjectAttributeRange -> ObjectAttributeRange -> Bool)
-> (ObjectAttributeRange -> ObjectAttributeRange -> Bool)
-> Eq ObjectAttributeRange
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
$c/= :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
== :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
$c== :: ObjectAttributeRange -> ObjectAttributeRange -> Bool
Prelude.Eq, ReadPrec [ObjectAttributeRange]
ReadPrec ObjectAttributeRange
Int -> ReadS ObjectAttributeRange
ReadS [ObjectAttributeRange]
(Int -> ReadS ObjectAttributeRange)
-> ReadS [ObjectAttributeRange]
-> ReadPrec ObjectAttributeRange
-> ReadPrec [ObjectAttributeRange]
-> Read ObjectAttributeRange
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ObjectAttributeRange]
$creadListPrec :: ReadPrec [ObjectAttributeRange]
readPrec :: ReadPrec ObjectAttributeRange
$creadPrec :: ReadPrec ObjectAttributeRange
readList :: ReadS [ObjectAttributeRange]
$creadList :: ReadS [ObjectAttributeRange]
readsPrec :: Int -> ReadS ObjectAttributeRange
$creadsPrec :: Int -> ReadS ObjectAttributeRange
Prelude.Read, Int -> ObjectAttributeRange -> ShowS
[ObjectAttributeRange] -> ShowS
ObjectAttributeRange -> String
(Int -> ObjectAttributeRange -> ShowS)
-> (ObjectAttributeRange -> String)
-> ([ObjectAttributeRange] -> ShowS)
-> Show ObjectAttributeRange
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ObjectAttributeRange] -> ShowS
$cshowList :: [ObjectAttributeRange] -> ShowS
show :: ObjectAttributeRange -> String
$cshow :: ObjectAttributeRange -> String
showsPrec :: Int -> ObjectAttributeRange -> ShowS
$cshowsPrec :: Int -> ObjectAttributeRange -> ShowS
Prelude.Show, (forall x. ObjectAttributeRange -> Rep ObjectAttributeRange x)
-> (forall x. Rep ObjectAttributeRange x -> ObjectAttributeRange)
-> Generic ObjectAttributeRange
forall x. Rep ObjectAttributeRange x -> ObjectAttributeRange
forall x. ObjectAttributeRange -> Rep ObjectAttributeRange x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ObjectAttributeRange x -> ObjectAttributeRange
$cfrom :: forall x. ObjectAttributeRange -> Rep ObjectAttributeRange x
Prelude.Generic)

-- |
-- Create a value of 'ObjectAttributeRange' 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:
--
-- 'range', 'objectAttributeRange_range' - The range of attribute values being selected.
--
-- 'attributeKey', 'objectAttributeRange_attributeKey' - The key of the attribute that the attribute range covers.
newObjectAttributeRange ::
  ObjectAttributeRange
newObjectAttributeRange :: ObjectAttributeRange
newObjectAttributeRange =
  ObjectAttributeRange' :: Maybe TypedAttributeValueRange
-> Maybe AttributeKey -> ObjectAttributeRange
ObjectAttributeRange'
    { $sel:range:ObjectAttributeRange' :: Maybe TypedAttributeValueRange
range = Maybe TypedAttributeValueRange
forall a. Maybe a
Prelude.Nothing,
      $sel:attributeKey:ObjectAttributeRange' :: Maybe AttributeKey
attributeKey = Maybe AttributeKey
forall a. Maybe a
Prelude.Nothing
    }

-- | The range of attribute values being selected.
objectAttributeRange_range :: Lens.Lens' ObjectAttributeRange (Prelude.Maybe TypedAttributeValueRange)
objectAttributeRange_range :: (Maybe TypedAttributeValueRange
 -> f (Maybe TypedAttributeValueRange))
-> ObjectAttributeRange -> f ObjectAttributeRange
objectAttributeRange_range = (ObjectAttributeRange -> Maybe TypedAttributeValueRange)
-> (ObjectAttributeRange
    -> Maybe TypedAttributeValueRange -> ObjectAttributeRange)
-> Lens
     ObjectAttributeRange
     ObjectAttributeRange
     (Maybe TypedAttributeValueRange)
     (Maybe TypedAttributeValueRange)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeRange' {Maybe TypedAttributeValueRange
range :: Maybe TypedAttributeValueRange
$sel:range:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe TypedAttributeValueRange
range} -> Maybe TypedAttributeValueRange
range) (\s :: ObjectAttributeRange
s@ObjectAttributeRange' {} Maybe TypedAttributeValueRange
a -> ObjectAttributeRange
s {$sel:range:ObjectAttributeRange' :: Maybe TypedAttributeValueRange
range = Maybe TypedAttributeValueRange
a} :: ObjectAttributeRange)

-- | The key of the attribute that the attribute range covers.
objectAttributeRange_attributeKey :: Lens.Lens' ObjectAttributeRange (Prelude.Maybe AttributeKey)
objectAttributeRange_attributeKey :: (Maybe AttributeKey -> f (Maybe AttributeKey))
-> ObjectAttributeRange -> f ObjectAttributeRange
objectAttributeRange_attributeKey = (ObjectAttributeRange -> Maybe AttributeKey)
-> (ObjectAttributeRange
    -> Maybe AttributeKey -> ObjectAttributeRange)
-> Lens
     ObjectAttributeRange
     ObjectAttributeRange
     (Maybe AttributeKey)
     (Maybe AttributeKey)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ObjectAttributeRange' {Maybe AttributeKey
attributeKey :: Maybe AttributeKey
$sel:attributeKey:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe AttributeKey
attributeKey} -> Maybe AttributeKey
attributeKey) (\s :: ObjectAttributeRange
s@ObjectAttributeRange' {} Maybe AttributeKey
a -> ObjectAttributeRange
s {$sel:attributeKey:ObjectAttributeRange' :: Maybe AttributeKey
attributeKey = Maybe AttributeKey
a} :: ObjectAttributeRange)

instance Prelude.Hashable ObjectAttributeRange

instance Prelude.NFData ObjectAttributeRange

instance Core.ToJSON ObjectAttributeRange where
  toJSON :: ObjectAttributeRange -> Value
toJSON ObjectAttributeRange' {Maybe AttributeKey
Maybe TypedAttributeValueRange
attributeKey :: Maybe AttributeKey
range :: Maybe TypedAttributeValueRange
$sel:attributeKey:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe AttributeKey
$sel:range:ObjectAttributeRange' :: ObjectAttributeRange -> Maybe TypedAttributeValueRange
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Range" Text -> TypedAttributeValueRange -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (TypedAttributeValueRange -> Pair)
-> Maybe TypedAttributeValueRange -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe TypedAttributeValueRange
range,
            (Text
"AttributeKey" Text -> AttributeKey -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (AttributeKey -> Pair) -> Maybe AttributeKey -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe AttributeKey
attributeKey
          ]
      )