{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Location.Types.DataSourceConfiguration where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:intendedUse:DataSourceConfiguration' :: Maybe IntendedUse
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 :: Lens' DataSourceConfiguration (Maybe IntendedUse)
dataSourceConfiguration_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 Data.FromJSON DataSourceConfiguration where
  parseJSON :: Value -> Parser DataSourceConfiguration
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"DataSourceConfiguration"
      ( \Object
x ->
          Maybe IntendedUse -> DataSourceConfiguration
DataSourceConfiguration'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"IntendedUse")
      )

instance Prelude.Hashable DataSourceConfiguration where
  hashWithSalt :: Int -> DataSourceConfiguration -> Int
hashWithSalt Int
_salt DataSourceConfiguration' {Maybe IntendedUse
intendedUse :: Maybe IntendedUse
$sel:intendedUse:DataSourceConfiguration' :: DataSourceConfiguration -> Maybe IntendedUse
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe IntendedUse
intendedUse

instance Prelude.NFData DataSourceConfiguration where
  rnf :: DataSourceConfiguration -> ()
rnf DataSourceConfiguration' {Maybe IntendedUse
intendedUse :: Maybe IntendedUse
$sel:intendedUse:DataSourceConfiguration' :: DataSourceConfiguration -> Maybe IntendedUse
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe IntendedUse
intendedUse

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