{-# 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.Pinpoint.Types.WriteSegmentRequest
-- 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.Pinpoint.Types.WriteSegmentRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.SegmentDimensions
import Amazonka.Pinpoint.Types.SegmentGroupList
import qualified Amazonka.Prelude as Prelude

-- | Specifies the configuration, dimension, and other settings for a
-- segment. A WriteSegmentRequest object can include a Dimensions object or
-- a SegmentGroups object, but not both.
--
-- /See:/ 'newWriteSegmentRequest' smart constructor.
data WriteSegmentRequest = WriteSegmentRequest'
  { -- | The segment group to use and the dimensions to apply to the group\'s
    -- base segments in order to build the segment. A segment group can consist
    -- of zero or more base segments. Your request can include only one segment
    -- group.
    WriteSegmentRequest -> Maybe SegmentGroupList
segmentGroups :: Prelude.Maybe SegmentGroupList,
    -- | The name of the segment.
    WriteSegmentRequest -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The criteria that define the dimensions for the segment.
    WriteSegmentRequest -> Maybe SegmentDimensions
dimensions :: Prelude.Maybe SegmentDimensions,
    -- | A string-to-string map of key-value pairs that defines the tags to
    -- associate with the segment. Each tag consists of a required tag key and
    -- an associated tag value.
    WriteSegmentRequest -> Maybe (HashMap Text Text)
tags :: Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text)
  }
  deriving (WriteSegmentRequest -> WriteSegmentRequest -> Bool
(WriteSegmentRequest -> WriteSegmentRequest -> Bool)
-> (WriteSegmentRequest -> WriteSegmentRequest -> Bool)
-> Eq WriteSegmentRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: WriteSegmentRequest -> WriteSegmentRequest -> Bool
$c/= :: WriteSegmentRequest -> WriteSegmentRequest -> Bool
== :: WriteSegmentRequest -> WriteSegmentRequest -> Bool
$c== :: WriteSegmentRequest -> WriteSegmentRequest -> Bool
Prelude.Eq, ReadPrec [WriteSegmentRequest]
ReadPrec WriteSegmentRequest
Int -> ReadS WriteSegmentRequest
ReadS [WriteSegmentRequest]
(Int -> ReadS WriteSegmentRequest)
-> ReadS [WriteSegmentRequest]
-> ReadPrec WriteSegmentRequest
-> ReadPrec [WriteSegmentRequest]
-> Read WriteSegmentRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [WriteSegmentRequest]
$creadListPrec :: ReadPrec [WriteSegmentRequest]
readPrec :: ReadPrec WriteSegmentRequest
$creadPrec :: ReadPrec WriteSegmentRequest
readList :: ReadS [WriteSegmentRequest]
$creadList :: ReadS [WriteSegmentRequest]
readsPrec :: Int -> ReadS WriteSegmentRequest
$creadsPrec :: Int -> ReadS WriteSegmentRequest
Prelude.Read, Int -> WriteSegmentRequest -> ShowS
[WriteSegmentRequest] -> ShowS
WriteSegmentRequest -> String
(Int -> WriteSegmentRequest -> ShowS)
-> (WriteSegmentRequest -> String)
-> ([WriteSegmentRequest] -> ShowS)
-> Show WriteSegmentRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [WriteSegmentRequest] -> ShowS
$cshowList :: [WriteSegmentRequest] -> ShowS
show :: WriteSegmentRequest -> String
$cshow :: WriteSegmentRequest -> String
showsPrec :: Int -> WriteSegmentRequest -> ShowS
$cshowsPrec :: Int -> WriteSegmentRequest -> ShowS
Prelude.Show, (forall x. WriteSegmentRequest -> Rep WriteSegmentRequest x)
-> (forall x. Rep WriteSegmentRequest x -> WriteSegmentRequest)
-> Generic WriteSegmentRequest
forall x. Rep WriteSegmentRequest x -> WriteSegmentRequest
forall x. WriteSegmentRequest -> Rep WriteSegmentRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep WriteSegmentRequest x -> WriteSegmentRequest
$cfrom :: forall x. WriteSegmentRequest -> Rep WriteSegmentRequest x
Prelude.Generic)

-- |
-- Create a value of 'WriteSegmentRequest' 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:
--
-- 'segmentGroups', 'writeSegmentRequest_segmentGroups' - The segment group to use and the dimensions to apply to the group\'s
-- base segments in order to build the segment. A segment group can consist
-- of zero or more base segments. Your request can include only one segment
-- group.
--
-- 'name', 'writeSegmentRequest_name' - The name of the segment.
--
-- 'dimensions', 'writeSegmentRequest_dimensions' - The criteria that define the dimensions for the segment.
--
-- 'tags', 'writeSegmentRequest_tags' - A string-to-string map of key-value pairs that defines the tags to
-- associate with the segment. Each tag consists of a required tag key and
-- an associated tag value.
newWriteSegmentRequest ::
  WriteSegmentRequest
newWriteSegmentRequest :: WriteSegmentRequest
newWriteSegmentRequest =
  WriteSegmentRequest' :: Maybe SegmentGroupList
-> Maybe Text
-> Maybe SegmentDimensions
-> Maybe (HashMap Text Text)
-> WriteSegmentRequest
WriteSegmentRequest'
    { $sel:segmentGroups:WriteSegmentRequest' :: Maybe SegmentGroupList
segmentGroups =
        Maybe SegmentGroupList
forall a. Maybe a
Prelude.Nothing,
      $sel:name:WriteSegmentRequest' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:dimensions:WriteSegmentRequest' :: Maybe SegmentDimensions
dimensions = Maybe SegmentDimensions
forall a. Maybe a
Prelude.Nothing,
      $sel:tags:WriteSegmentRequest' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
forall a. Maybe a
Prelude.Nothing
    }

-- | The segment group to use and the dimensions to apply to the group\'s
-- base segments in order to build the segment. A segment group can consist
-- of zero or more base segments. Your request can include only one segment
-- group.
writeSegmentRequest_segmentGroups :: Lens.Lens' WriteSegmentRequest (Prelude.Maybe SegmentGroupList)
writeSegmentRequest_segmentGroups :: (Maybe SegmentGroupList -> f (Maybe SegmentGroupList))
-> WriteSegmentRequest -> f WriteSegmentRequest
writeSegmentRequest_segmentGroups = (WriteSegmentRequest -> Maybe SegmentGroupList)
-> (WriteSegmentRequest
    -> Maybe SegmentGroupList -> WriteSegmentRequest)
-> Lens
     WriteSegmentRequest
     WriteSegmentRequest
     (Maybe SegmentGroupList)
     (Maybe SegmentGroupList)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteSegmentRequest' {Maybe SegmentGroupList
segmentGroups :: Maybe SegmentGroupList
$sel:segmentGroups:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe SegmentGroupList
segmentGroups} -> Maybe SegmentGroupList
segmentGroups) (\s :: WriteSegmentRequest
s@WriteSegmentRequest' {} Maybe SegmentGroupList
a -> WriteSegmentRequest
s {$sel:segmentGroups:WriteSegmentRequest' :: Maybe SegmentGroupList
segmentGroups = Maybe SegmentGroupList
a} :: WriteSegmentRequest)

-- | The name of the segment.
writeSegmentRequest_name :: Lens.Lens' WriteSegmentRequest (Prelude.Maybe Prelude.Text)
writeSegmentRequest_name :: (Maybe Text -> f (Maybe Text))
-> WriteSegmentRequest -> f WriteSegmentRequest
writeSegmentRequest_name = (WriteSegmentRequest -> Maybe Text)
-> (WriteSegmentRequest -> Maybe Text -> WriteSegmentRequest)
-> Lens
     WriteSegmentRequest WriteSegmentRequest (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteSegmentRequest' {Maybe Text
name :: Maybe Text
$sel:name:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe Text
name} -> Maybe Text
name) (\s :: WriteSegmentRequest
s@WriteSegmentRequest' {} Maybe Text
a -> WriteSegmentRequest
s {$sel:name:WriteSegmentRequest' :: Maybe Text
name = Maybe Text
a} :: WriteSegmentRequest)

-- | The criteria that define the dimensions for the segment.
writeSegmentRequest_dimensions :: Lens.Lens' WriteSegmentRequest (Prelude.Maybe SegmentDimensions)
writeSegmentRequest_dimensions :: (Maybe SegmentDimensions -> f (Maybe SegmentDimensions))
-> WriteSegmentRequest -> f WriteSegmentRequest
writeSegmentRequest_dimensions = (WriteSegmentRequest -> Maybe SegmentDimensions)
-> (WriteSegmentRequest
    -> Maybe SegmentDimensions -> WriteSegmentRequest)
-> Lens
     WriteSegmentRequest
     WriteSegmentRequest
     (Maybe SegmentDimensions)
     (Maybe SegmentDimensions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteSegmentRequest' {Maybe SegmentDimensions
dimensions :: Maybe SegmentDimensions
$sel:dimensions:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe SegmentDimensions
dimensions} -> Maybe SegmentDimensions
dimensions) (\s :: WriteSegmentRequest
s@WriteSegmentRequest' {} Maybe SegmentDimensions
a -> WriteSegmentRequest
s {$sel:dimensions:WriteSegmentRequest' :: Maybe SegmentDimensions
dimensions = Maybe SegmentDimensions
a} :: WriteSegmentRequest)

-- | A string-to-string map of key-value pairs that defines the tags to
-- associate with the segment. Each tag consists of a required tag key and
-- an associated tag value.
writeSegmentRequest_tags :: Lens.Lens' WriteSegmentRequest (Prelude.Maybe (Prelude.HashMap Prelude.Text Prelude.Text))
writeSegmentRequest_tags :: (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> WriteSegmentRequest -> f WriteSegmentRequest
writeSegmentRequest_tags = (WriteSegmentRequest -> Maybe (HashMap Text Text))
-> (WriteSegmentRequest
    -> Maybe (HashMap Text Text) -> WriteSegmentRequest)
-> Lens
     WriteSegmentRequest
     WriteSegmentRequest
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\WriteSegmentRequest' {Maybe (HashMap Text Text)
tags :: Maybe (HashMap Text Text)
$sel:tags:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe (HashMap Text Text)
tags} -> Maybe (HashMap Text Text)
tags) (\s :: WriteSegmentRequest
s@WriteSegmentRequest' {} Maybe (HashMap Text Text)
a -> WriteSegmentRequest
s {$sel:tags:WriteSegmentRequest' :: Maybe (HashMap Text Text)
tags = Maybe (HashMap Text Text)
a} :: WriteSegmentRequest) ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
 -> WriteSegmentRequest -> f WriteSegmentRequest)
-> ((Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
    -> Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> (Maybe (HashMap Text Text) -> f (Maybe (HashMap Text Text)))
-> WriteSegmentRequest
-> f WriteSegmentRequest
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
-> Iso
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
     (Maybe (HashMap Text Text))
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
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
  (HashMap Text Text)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable WriteSegmentRequest

instance Prelude.NFData WriteSegmentRequest

instance Core.ToJSON WriteSegmentRequest where
  toJSON :: WriteSegmentRequest -> Value
toJSON WriteSegmentRequest' {Maybe Text
Maybe (HashMap Text Text)
Maybe SegmentDimensions
Maybe SegmentGroupList
tags :: Maybe (HashMap Text Text)
dimensions :: Maybe SegmentDimensions
name :: Maybe Text
segmentGroups :: Maybe SegmentGroupList
$sel:tags:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe (HashMap Text Text)
$sel:dimensions:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe SegmentDimensions
$sel:name:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe Text
$sel:segmentGroups:WriteSegmentRequest' :: WriteSegmentRequest -> Maybe SegmentGroupList
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SegmentGroups" Text -> SegmentGroupList -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SegmentGroupList -> Pair) -> Maybe SegmentGroupList -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentGroupList
segmentGroups,
            (Text
"Name" 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
name,
            (Text
"Dimensions" Text -> SegmentDimensions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SegmentDimensions -> Pair)
-> Maybe SegmentDimensions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentDimensions
dimensions,
            (Text
"tags" Text -> HashMap Text Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text Text -> Pair)
-> Maybe (HashMap Text Text) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text Text)
tags
          ]
      )