{-# 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.Location.Types.DataSourceConfiguration
-- 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.Location.Types.DataSourceConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types.IntendedUse
import qualified Amazonka.Prelude as Prelude

-- | Specifies the data storage option chosen for requesting Places.
--
-- When using Amazon Location Places:
--
-- -   If using HERE Technologies as a data provider, you can\'t store
--     results for locations in Japan by setting @IntendedUse@ to
--     @Storage@. parameter.
--
-- -   Under the @MobileAssetTracking@ or @MobilAssetManagement@ pricing
--     plan, you can\'t store results from your place index resources by
--     setting @IntendedUse@ to @Storage@. This returns a validation
--     exception error.
--
-- For more information, see the
-- <https://aws.amazon.com/service-terms/ AWS Service Terms> for Amazon
-- Location Service.
--
-- /See:/ 'newDataSourceConfiguration' smart constructor.
data DataSourceConfiguration = DataSourceConfiguration'
  { -- | Specifies how the results of an operation will be stored by the caller.
    --
    -- Valid values include:
    --
    -- -   @SingleUse@ specifies that the results won\'t be stored.
    --
    -- -   @Storage@ specifies that the result can be cached or stored in a
    --     database.
    --
    -- Default value: @SingleUse@
    DataSourceConfiguration -> Maybe IntendedUse
intendedUse :: Prelude.Maybe IntendedUse
  }
  deriving (DataSourceConfiguration -> DataSourceConfiguration -> Bool
(DataSourceConfiguration -> DataSourceConfiguration -> Bool)
-> (DataSourceConfiguration -> DataSourceConfiguration -> Bool)
-> Eq DataSourceConfiguration
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DataSourceConfiguration -> DataSourceConfiguration -> Bool
$c/= :: DataSourceConfiguration -> DataSourceConfiguration -> Bool
== :: DataSourceConfiguration -> DataSourceConfiguration -> Bool
$c== :: DataSourceConfiguration -> DataSourceConfiguration -> Bool
Prelude.Eq, ReadPrec [DataSourceConfiguration]
ReadPrec DataSourceConfiguration
Int -> ReadS DataSourceConfiguration
ReadS [DataSourceConfiguration]
(Int -> ReadS DataSourceConfiguration)
-> ReadS [DataSourceConfiguration]
-> ReadPrec DataSourceConfiguration
-> ReadPrec [DataSourceConfiguration]
-> Read DataSourceConfiguration
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DataSourceConfiguration]
$creadListPrec :: ReadPrec [DataSourceConfiguration]
readPrec :: ReadPrec DataSourceConfiguration
$creadPrec :: ReadPrec DataSourceConfiguration
readList :: ReadS [DataSourceConfiguration]
$creadList :: ReadS [DataSourceConfiguration]
readsPrec :: Int -> ReadS DataSourceConfiguration
$creadsPrec :: Int -> ReadS DataSourceConfiguration
Prelude.Read, Int -> DataSourceConfiguration -> ShowS
[DataSourceConfiguration] -> ShowS
DataSourceConfiguration -> String
(Int -> DataSourceConfiguration -> ShowS)
-> (DataSourceConfiguration -> String)
-> ([DataSourceConfiguration] -> ShowS)
-> Show DataSourceConfiguration
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DataSourceConfiguration] -> ShowS
$cshowList :: [DataSourceConfiguration] -> ShowS
show :: DataSourceConfiguration -> String
$cshow :: DataSourceConfiguration -> String
showsPrec :: Int -> DataSourceConfiguration -> ShowS
$cshowsPrec :: Int -> DataSourceConfiguration -> ShowS
Prelude.Show, (forall x.
 DataSourceConfiguration -> Rep DataSourceConfiguration x)
-> (forall x.
    Rep DataSourceConfiguration x -> DataSourceConfiguration)
-> Generic DataSourceConfiguration
forall x. Rep DataSourceConfiguration x -> DataSourceConfiguration
forall x. DataSourceConfiguration -> Rep DataSourceConfiguration x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DataSourceConfiguration x -> DataSourceConfiguration
$cfrom :: forall x. DataSourceConfiguration -> Rep DataSourceConfiguration x
Prelude.Generic)

-- |
-- Create a value of 'DataSourceConfiguration' 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:
--
-- 'intendedUse', 'dataSourceConfiguration_intendedUse' - Specifies how the results of an operation will be stored by the caller.
--
-- Valid values include:
--
-- -   @SingleUse@ specifies that the results won\'t be stored.
--
-- -   @Storage@ specifies that the result can be cached or stored in a
--     database.
--
-- Default value: @SingleUse@
newDataSourceConfiguration ::
  DataSourceConfiguration
newDataSourceConfiguration :: DataSourceConfiguration
newDataSourceConfiguration =
  DataSourceConfiguration' :: Maybe IntendedUse -> DataSourceConfiguration
DataSourceConfiguration'
    { $sel:intendedUse:DataSourceConfiguration' :: Maybe IntendedUse
intendedUse =
        Maybe IntendedUse
forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies how the results of an operation will be stored by the caller.
--
-- Valid values include:
--
-- -   @SingleUse@ specifies that the results won\'t be stored.
--
-- -   @Storage@ specifies that the result can be cached or stored in a
--     database.
--
-- Default value: @SingleUse@
dataSourceConfiguration_intendedUse :: Lens.Lens' DataSourceConfiguration (Prelude.Maybe IntendedUse)
dataSourceConfiguration_intendedUse :: (Maybe IntendedUse -> f (Maybe IntendedUse))
-> DataSourceConfiguration -> f DataSourceConfiguration
dataSourceConfiguration_intendedUse = (DataSourceConfiguration -> Maybe IntendedUse)
-> (DataSourceConfiguration
    -> Maybe IntendedUse -> DataSourceConfiguration)
-> Lens
     DataSourceConfiguration
     DataSourceConfiguration
     (Maybe IntendedUse)
     (Maybe IntendedUse)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DataSourceConfiguration' {Maybe IntendedUse
intendedUse :: Maybe IntendedUse
$sel:intendedUse:DataSourceConfiguration' :: DataSourceConfiguration -> Maybe IntendedUse
intendedUse} -> Maybe IntendedUse
intendedUse) (\s :: DataSourceConfiguration
s@DataSourceConfiguration' {} Maybe IntendedUse
a -> DataSourceConfiguration
s {$sel:intendedUse:DataSourceConfiguration' :: Maybe IntendedUse
intendedUse = Maybe IntendedUse
a} :: DataSourceConfiguration)

instance Core.FromJSON DataSourceConfiguration where
  parseJSON :: Value -> Parser DataSourceConfiguration
parseJSON =
    String
-> (Object -> Parser DataSourceConfiguration)
-> Value
-> Parser DataSourceConfiguration
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"DataSourceConfiguration"
      ( \Object
x ->
          Maybe IntendedUse -> DataSourceConfiguration
DataSourceConfiguration'
            (Maybe IntendedUse -> DataSourceConfiguration)
-> Parser (Maybe IntendedUse) -> Parser DataSourceConfiguration
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe IntendedUse)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"IntendedUse")
      )

instance Prelude.Hashable DataSourceConfiguration

instance Prelude.NFData DataSourceConfiguration

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