{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.IoTAnalytics.UpdateDatastore
-- 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)
--
-- Used to update the settings of a data store.
module Amazonka.IoTAnalytics.UpdateDatastore
  ( -- * Creating a Request
    UpdateDatastore (..),
    newUpdateDatastore,

    -- * Request Lenses
    updateDatastore_fileFormatConfiguration,
    updateDatastore_retentionPeriod,
    updateDatastore_datastoreStorage,
    updateDatastore_datastoreName,

    -- * Destructuring the Response
    UpdateDatastoreResponse (..),
    newUpdateDatastoreResponse,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.IoTAnalytics.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newUpdateDatastore' smart constructor.
data UpdateDatastore = UpdateDatastore'
  { -- | Contains the configuration information of file formats. IoT Analytics
    -- data stores support JSON and <https://parquet.apache.org/ Parquet>.
    --
    -- The default file format is JSON. You can specify only one format.
    --
    -- You can\'t change the file format after you create the data store.
    UpdateDatastore -> Maybe FileFormatConfiguration
fileFormatConfiguration :: Prelude.Maybe FileFormatConfiguration,
    -- | How long, in days, message data is kept for the data store. The
    -- retention period can\'t be updated if the data store\'s Amazon S3
    -- storage is customer-managed.
    UpdateDatastore -> Maybe RetentionPeriod
retentionPeriod :: Prelude.Maybe RetentionPeriod,
    -- | Where data in a data store is stored.. You can choose @serviceManagedS3@
    -- storage, @customerManagedS3@ storage, or @iotSiteWiseMultiLayerStorage@
    -- storage. The default is @serviceManagedS3@. You can\'t change the choice
    -- of Amazon S3 storage after your data store is created.
    UpdateDatastore -> Maybe DatastoreStorage
datastoreStorage :: Prelude.Maybe DatastoreStorage,
    -- | The name of the data store to be updated.
    UpdateDatastore -> Text
datastoreName :: Prelude.Text
  }
  deriving (UpdateDatastore -> UpdateDatastore -> Bool
(UpdateDatastore -> UpdateDatastore -> Bool)
-> (UpdateDatastore -> UpdateDatastore -> Bool)
-> Eq UpdateDatastore
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDatastore -> UpdateDatastore -> Bool
$c/= :: UpdateDatastore -> UpdateDatastore -> Bool
== :: UpdateDatastore -> UpdateDatastore -> Bool
$c== :: UpdateDatastore -> UpdateDatastore -> Bool
Prelude.Eq, ReadPrec [UpdateDatastore]
ReadPrec UpdateDatastore
Int -> ReadS UpdateDatastore
ReadS [UpdateDatastore]
(Int -> ReadS UpdateDatastore)
-> ReadS [UpdateDatastore]
-> ReadPrec UpdateDatastore
-> ReadPrec [UpdateDatastore]
-> Read UpdateDatastore
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDatastore]
$creadListPrec :: ReadPrec [UpdateDatastore]
readPrec :: ReadPrec UpdateDatastore
$creadPrec :: ReadPrec UpdateDatastore
readList :: ReadS [UpdateDatastore]
$creadList :: ReadS [UpdateDatastore]
readsPrec :: Int -> ReadS UpdateDatastore
$creadsPrec :: Int -> ReadS UpdateDatastore
Prelude.Read, Int -> UpdateDatastore -> ShowS
[UpdateDatastore] -> ShowS
UpdateDatastore -> String
(Int -> UpdateDatastore -> ShowS)
-> (UpdateDatastore -> String)
-> ([UpdateDatastore] -> ShowS)
-> Show UpdateDatastore
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDatastore] -> ShowS
$cshowList :: [UpdateDatastore] -> ShowS
show :: UpdateDatastore -> String
$cshow :: UpdateDatastore -> String
showsPrec :: Int -> UpdateDatastore -> ShowS
$cshowsPrec :: Int -> UpdateDatastore -> ShowS
Prelude.Show, (forall x. UpdateDatastore -> Rep UpdateDatastore x)
-> (forall x. Rep UpdateDatastore x -> UpdateDatastore)
-> Generic UpdateDatastore
forall x. Rep UpdateDatastore x -> UpdateDatastore
forall x. UpdateDatastore -> Rep UpdateDatastore x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDatastore x -> UpdateDatastore
$cfrom :: forall x. UpdateDatastore -> Rep UpdateDatastore x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDatastore' 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:
--
-- 'fileFormatConfiguration', 'updateDatastore_fileFormatConfiguration' - Contains the configuration information of file formats. IoT Analytics
-- data stores support JSON and <https://parquet.apache.org/ Parquet>.
--
-- The default file format is JSON. You can specify only one format.
--
-- You can\'t change the file format after you create the data store.
--
-- 'retentionPeriod', 'updateDatastore_retentionPeriod' - How long, in days, message data is kept for the data store. The
-- retention period can\'t be updated if the data store\'s Amazon S3
-- storage is customer-managed.
--
-- 'datastoreStorage', 'updateDatastore_datastoreStorage' - Where data in a data store is stored.. You can choose @serviceManagedS3@
-- storage, @customerManagedS3@ storage, or @iotSiteWiseMultiLayerStorage@
-- storage. The default is @serviceManagedS3@. You can\'t change the choice
-- of Amazon S3 storage after your data store is created.
--
-- 'datastoreName', 'updateDatastore_datastoreName' - The name of the data store to be updated.
newUpdateDatastore ::
  -- | 'datastoreName'
  Prelude.Text ->
  UpdateDatastore
newUpdateDatastore :: Text -> UpdateDatastore
newUpdateDatastore Text
pDatastoreName_ =
  UpdateDatastore' :: Maybe FileFormatConfiguration
-> Maybe RetentionPeriod
-> Maybe DatastoreStorage
-> Text
-> UpdateDatastore
UpdateDatastore'
    { $sel:fileFormatConfiguration:UpdateDatastore' :: Maybe FileFormatConfiguration
fileFormatConfiguration =
        Maybe FileFormatConfiguration
forall a. Maybe a
Prelude.Nothing,
      $sel:retentionPeriod:UpdateDatastore' :: Maybe RetentionPeriod
retentionPeriod = Maybe RetentionPeriod
forall a. Maybe a
Prelude.Nothing,
      $sel:datastoreStorage:UpdateDatastore' :: Maybe DatastoreStorage
datastoreStorage = Maybe DatastoreStorage
forall a. Maybe a
Prelude.Nothing,
      $sel:datastoreName:UpdateDatastore' :: Text
datastoreName = Text
pDatastoreName_
    }

-- | Contains the configuration information of file formats. IoT Analytics
-- data stores support JSON and <https://parquet.apache.org/ Parquet>.
--
-- The default file format is JSON. You can specify only one format.
--
-- You can\'t change the file format after you create the data store.
updateDatastore_fileFormatConfiguration :: Lens.Lens' UpdateDatastore (Prelude.Maybe FileFormatConfiguration)
updateDatastore_fileFormatConfiguration :: (Maybe FileFormatConfiguration
 -> f (Maybe FileFormatConfiguration))
-> UpdateDatastore -> f UpdateDatastore
updateDatastore_fileFormatConfiguration = (UpdateDatastore -> Maybe FileFormatConfiguration)
-> (UpdateDatastore
    -> Maybe FileFormatConfiguration -> UpdateDatastore)
-> Lens
     UpdateDatastore
     UpdateDatastore
     (Maybe FileFormatConfiguration)
     (Maybe FileFormatConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDatastore' {Maybe FileFormatConfiguration
fileFormatConfiguration :: Maybe FileFormatConfiguration
$sel:fileFormatConfiguration:UpdateDatastore' :: UpdateDatastore -> Maybe FileFormatConfiguration
fileFormatConfiguration} -> Maybe FileFormatConfiguration
fileFormatConfiguration) (\s :: UpdateDatastore
s@UpdateDatastore' {} Maybe FileFormatConfiguration
a -> UpdateDatastore
s {$sel:fileFormatConfiguration:UpdateDatastore' :: Maybe FileFormatConfiguration
fileFormatConfiguration = Maybe FileFormatConfiguration
a} :: UpdateDatastore)

-- | How long, in days, message data is kept for the data store. The
-- retention period can\'t be updated if the data store\'s Amazon S3
-- storage is customer-managed.
updateDatastore_retentionPeriod :: Lens.Lens' UpdateDatastore (Prelude.Maybe RetentionPeriod)
updateDatastore_retentionPeriod :: (Maybe RetentionPeriod -> f (Maybe RetentionPeriod))
-> UpdateDatastore -> f UpdateDatastore
updateDatastore_retentionPeriod = (UpdateDatastore -> Maybe RetentionPeriod)
-> (UpdateDatastore -> Maybe RetentionPeriod -> UpdateDatastore)
-> Lens
     UpdateDatastore
     UpdateDatastore
     (Maybe RetentionPeriod)
     (Maybe RetentionPeriod)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDatastore' {Maybe RetentionPeriod
retentionPeriod :: Maybe RetentionPeriod
$sel:retentionPeriod:UpdateDatastore' :: UpdateDatastore -> Maybe RetentionPeriod
retentionPeriod} -> Maybe RetentionPeriod
retentionPeriod) (\s :: UpdateDatastore
s@UpdateDatastore' {} Maybe RetentionPeriod
a -> UpdateDatastore
s {$sel:retentionPeriod:UpdateDatastore' :: Maybe RetentionPeriod
retentionPeriod = Maybe RetentionPeriod
a} :: UpdateDatastore)

-- | Where data in a data store is stored.. You can choose @serviceManagedS3@
-- storage, @customerManagedS3@ storage, or @iotSiteWiseMultiLayerStorage@
-- storage. The default is @serviceManagedS3@. You can\'t change the choice
-- of Amazon S3 storage after your data store is created.
updateDatastore_datastoreStorage :: Lens.Lens' UpdateDatastore (Prelude.Maybe DatastoreStorage)
updateDatastore_datastoreStorage :: (Maybe DatastoreStorage -> f (Maybe DatastoreStorage))
-> UpdateDatastore -> f UpdateDatastore
updateDatastore_datastoreStorage = (UpdateDatastore -> Maybe DatastoreStorage)
-> (UpdateDatastore -> Maybe DatastoreStorage -> UpdateDatastore)
-> Lens
     UpdateDatastore
     UpdateDatastore
     (Maybe DatastoreStorage)
     (Maybe DatastoreStorage)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDatastore' {Maybe DatastoreStorage
datastoreStorage :: Maybe DatastoreStorage
$sel:datastoreStorage:UpdateDatastore' :: UpdateDatastore -> Maybe DatastoreStorage
datastoreStorage} -> Maybe DatastoreStorage
datastoreStorage) (\s :: UpdateDatastore
s@UpdateDatastore' {} Maybe DatastoreStorage
a -> UpdateDatastore
s {$sel:datastoreStorage:UpdateDatastore' :: Maybe DatastoreStorage
datastoreStorage = Maybe DatastoreStorage
a} :: UpdateDatastore)

-- | The name of the data store to be updated.
updateDatastore_datastoreName :: Lens.Lens' UpdateDatastore Prelude.Text
updateDatastore_datastoreName :: (Text -> f Text) -> UpdateDatastore -> f UpdateDatastore
updateDatastore_datastoreName = (UpdateDatastore -> Text)
-> (UpdateDatastore -> Text -> UpdateDatastore)
-> Lens UpdateDatastore UpdateDatastore Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDatastore' {Text
datastoreName :: Text
$sel:datastoreName:UpdateDatastore' :: UpdateDatastore -> Text
datastoreName} -> Text
datastoreName) (\s :: UpdateDatastore
s@UpdateDatastore' {} Text
a -> UpdateDatastore
s {$sel:datastoreName:UpdateDatastore' :: Text
datastoreName = Text
a} :: UpdateDatastore)

instance Core.AWSRequest UpdateDatastore where
  type
    AWSResponse UpdateDatastore =
      UpdateDatastoreResponse
  request :: UpdateDatastore -> Request UpdateDatastore
request = Service -> UpdateDatastore -> Request UpdateDatastore
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDatastore
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDatastore)))
response =
    AWSResponse UpdateDatastore
-> Logger
-> Service
-> Proxy UpdateDatastore
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDatastore)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateDatastore
UpdateDatastoreResponse
UpdateDatastoreResponse'

instance Prelude.Hashable UpdateDatastore

instance Prelude.NFData UpdateDatastore

instance Core.ToHeaders UpdateDatastore where
  toHeaders :: UpdateDatastore -> [Header]
toHeaders = [Header] -> UpdateDatastore -> [Header]
forall a b. a -> b -> a
Prelude.const [Header]
forall a. Monoid a => a
Prelude.mempty

instance Core.ToJSON UpdateDatastore where
  toJSON :: UpdateDatastore -> Value
toJSON UpdateDatastore' {Maybe RetentionPeriod
Maybe FileFormatConfiguration
Maybe DatastoreStorage
Text
datastoreName :: Text
datastoreStorage :: Maybe DatastoreStorage
retentionPeriod :: Maybe RetentionPeriod
fileFormatConfiguration :: Maybe FileFormatConfiguration
$sel:datastoreName:UpdateDatastore' :: UpdateDatastore -> Text
$sel:datastoreStorage:UpdateDatastore' :: UpdateDatastore -> Maybe DatastoreStorage
$sel:retentionPeriod:UpdateDatastore' :: UpdateDatastore -> Maybe RetentionPeriod
$sel:fileFormatConfiguration:UpdateDatastore' :: UpdateDatastore -> Maybe FileFormatConfiguration
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"fileFormatConfiguration" Text -> FileFormatConfiguration -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (FileFormatConfiguration -> Pair)
-> Maybe FileFormatConfiguration -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe FileFormatConfiguration
fileFormatConfiguration,
            (Text
"retentionPeriod" Text -> RetentionPeriod -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (RetentionPeriod -> Pair) -> Maybe RetentionPeriod -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RetentionPeriod
retentionPeriod,
            (Text
"datastoreStorage" Text -> DatastoreStorage -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DatastoreStorage -> Pair) -> Maybe DatastoreStorage -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DatastoreStorage
datastoreStorage
          ]
      )

instance Core.ToPath UpdateDatastore where
  toPath :: UpdateDatastore -> ByteString
toPath UpdateDatastore' {Maybe RetentionPeriod
Maybe FileFormatConfiguration
Maybe DatastoreStorage
Text
datastoreName :: Text
datastoreStorage :: Maybe DatastoreStorage
retentionPeriod :: Maybe RetentionPeriod
fileFormatConfiguration :: Maybe FileFormatConfiguration
$sel:datastoreName:UpdateDatastore' :: UpdateDatastore -> Text
$sel:datastoreStorage:UpdateDatastore' :: UpdateDatastore -> Maybe DatastoreStorage
$sel:retentionPeriod:UpdateDatastore' :: UpdateDatastore -> Maybe RetentionPeriod
$sel:fileFormatConfiguration:UpdateDatastore' :: UpdateDatastore -> Maybe FileFormatConfiguration
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/datastores/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
datastoreName]

instance Core.ToQuery UpdateDatastore where
  toQuery :: UpdateDatastore -> QueryString
toQuery = QueryString -> UpdateDatastore -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newUpdateDatastoreResponse' smart constructor.
data UpdateDatastoreResponse = UpdateDatastoreResponse'
  {
  }
  deriving (UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool
(UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool)
-> (UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool)
-> Eq UpdateDatastoreResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool
$c/= :: UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool
== :: UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool
$c== :: UpdateDatastoreResponse -> UpdateDatastoreResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDatastoreResponse]
ReadPrec UpdateDatastoreResponse
Int -> ReadS UpdateDatastoreResponse
ReadS [UpdateDatastoreResponse]
(Int -> ReadS UpdateDatastoreResponse)
-> ReadS [UpdateDatastoreResponse]
-> ReadPrec UpdateDatastoreResponse
-> ReadPrec [UpdateDatastoreResponse]
-> Read UpdateDatastoreResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDatastoreResponse]
$creadListPrec :: ReadPrec [UpdateDatastoreResponse]
readPrec :: ReadPrec UpdateDatastoreResponse
$creadPrec :: ReadPrec UpdateDatastoreResponse
readList :: ReadS [UpdateDatastoreResponse]
$creadList :: ReadS [UpdateDatastoreResponse]
readsPrec :: Int -> ReadS UpdateDatastoreResponse
$creadsPrec :: Int -> ReadS UpdateDatastoreResponse
Prelude.Read, Int -> UpdateDatastoreResponse -> ShowS
[UpdateDatastoreResponse] -> ShowS
UpdateDatastoreResponse -> String
(Int -> UpdateDatastoreResponse -> ShowS)
-> (UpdateDatastoreResponse -> String)
-> ([UpdateDatastoreResponse] -> ShowS)
-> Show UpdateDatastoreResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDatastoreResponse] -> ShowS
$cshowList :: [UpdateDatastoreResponse] -> ShowS
show :: UpdateDatastoreResponse -> String
$cshow :: UpdateDatastoreResponse -> String
showsPrec :: Int -> UpdateDatastoreResponse -> ShowS
$cshowsPrec :: Int -> UpdateDatastoreResponse -> ShowS
Prelude.Show, (forall x.
 UpdateDatastoreResponse -> Rep UpdateDatastoreResponse x)
-> (forall x.
    Rep UpdateDatastoreResponse x -> UpdateDatastoreResponse)
-> Generic UpdateDatastoreResponse
forall x. Rep UpdateDatastoreResponse x -> UpdateDatastoreResponse
forall x. UpdateDatastoreResponse -> Rep UpdateDatastoreResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDatastoreResponse x -> UpdateDatastoreResponse
$cfrom :: forall x. UpdateDatastoreResponse -> Rep UpdateDatastoreResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDatastoreResponse' 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.
newUpdateDatastoreResponse ::
  UpdateDatastoreResponse
newUpdateDatastoreResponse :: UpdateDatastoreResponse
newUpdateDatastoreResponse = UpdateDatastoreResponse
UpdateDatastoreResponse'

instance Prelude.NFData UpdateDatastoreResponse