{-# 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.CognitoSync.UpdateRecords
-- 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)
--
-- Posts updates to records and adds and deletes records for a dataset and
-- user.
--
-- The sync count in the record patch is your last known sync count for
-- that record. The server will reject an UpdateRecords request with a
-- ResourceConflictException if you try to patch a record with a new value
-- but a stale sync count.
--
-- For example, if the sync count on the server is 5 for a key called
-- highScore and you try and submit a new highScore with sync count of 4,
-- the request will be rejected. To obtain the current sync count for a
-- record, call ListRecords. On a successful update of the record, the
-- response returns the new sync count for that record. You should present
-- that sync count the next time you try to update that same record. When
-- the record does not exist, specify the sync count as 0.
--
-- This API can be called with temporary user credentials provided by
-- Cognito Identity or with developer credentials.
module Amazonka.CognitoSync.UpdateRecords
  ( -- * Creating a Request
    UpdateRecords (..),
    newUpdateRecords,

    -- * Request Lenses
    updateRecords_recordPatches,
    updateRecords_deviceId,
    updateRecords_clientContext,
    updateRecords_identityPoolId,
    updateRecords_identityId,
    updateRecords_datasetName,
    updateRecords_syncSessionToken,

    -- * Destructuring the Response
    UpdateRecordsResponse (..),
    newUpdateRecordsResponse,

    -- * Response Lenses
    updateRecordsResponse_records,
    updateRecordsResponse_httpStatus,
  )
where

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

-- | A request to post updates to records or add and delete records for a
-- dataset and user.
--
-- /See:/ 'newUpdateRecords' smart constructor.
data UpdateRecords = UpdateRecords'
  { -- | A list of patch operations.
    UpdateRecords -> Maybe [RecordPatch]
recordPatches :: Prelude.Maybe [RecordPatch],
    -- | The unique ID generated for this device by Cognito.
    UpdateRecords -> Maybe Text
deviceId :: Prelude.Maybe Prelude.Text,
    -- | Intended to supply a device ID that will populate the lastModifiedBy
    -- field referenced in other methods. The ClientContext field is not yet
    -- implemented.
    UpdateRecords -> Maybe Text
clientContext :: Prelude.Maybe Prelude.Text,
    -- | A name-spaced GUID (for example,
    -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
    -- Cognito. GUID generation is unique within a region.
    UpdateRecords -> Text
identityPoolId :: Prelude.Text,
    -- | A name-spaced GUID (for example,
    -- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
    -- Cognito. GUID generation is unique within a region.
    UpdateRecords -> Text
identityId :: Prelude.Text,
    -- | A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9,
    -- \'_\' (underscore), \'-\' (dash), and \'.\' (dot).
    UpdateRecords -> Text
datasetName :: Prelude.Text,
    -- | The SyncSessionToken returned by a previous call to ListRecords for this
    -- dataset and identity.
    UpdateRecords -> Text
syncSessionToken :: Prelude.Text
  }
  deriving (UpdateRecords -> UpdateRecords -> Bool
(UpdateRecords -> UpdateRecords -> Bool)
-> (UpdateRecords -> UpdateRecords -> Bool) -> Eq UpdateRecords
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRecords -> UpdateRecords -> Bool
$c/= :: UpdateRecords -> UpdateRecords -> Bool
== :: UpdateRecords -> UpdateRecords -> Bool
$c== :: UpdateRecords -> UpdateRecords -> Bool
Prelude.Eq, ReadPrec [UpdateRecords]
ReadPrec UpdateRecords
Int -> ReadS UpdateRecords
ReadS [UpdateRecords]
(Int -> ReadS UpdateRecords)
-> ReadS [UpdateRecords]
-> ReadPrec UpdateRecords
-> ReadPrec [UpdateRecords]
-> Read UpdateRecords
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRecords]
$creadListPrec :: ReadPrec [UpdateRecords]
readPrec :: ReadPrec UpdateRecords
$creadPrec :: ReadPrec UpdateRecords
readList :: ReadS [UpdateRecords]
$creadList :: ReadS [UpdateRecords]
readsPrec :: Int -> ReadS UpdateRecords
$creadsPrec :: Int -> ReadS UpdateRecords
Prelude.Read, Int -> UpdateRecords -> ShowS
[UpdateRecords] -> ShowS
UpdateRecords -> String
(Int -> UpdateRecords -> ShowS)
-> (UpdateRecords -> String)
-> ([UpdateRecords] -> ShowS)
-> Show UpdateRecords
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRecords] -> ShowS
$cshowList :: [UpdateRecords] -> ShowS
show :: UpdateRecords -> String
$cshow :: UpdateRecords -> String
showsPrec :: Int -> UpdateRecords -> ShowS
$cshowsPrec :: Int -> UpdateRecords -> ShowS
Prelude.Show, (forall x. UpdateRecords -> Rep UpdateRecords x)
-> (forall x. Rep UpdateRecords x -> UpdateRecords)
-> Generic UpdateRecords
forall x. Rep UpdateRecords x -> UpdateRecords
forall x. UpdateRecords -> Rep UpdateRecords x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRecords x -> UpdateRecords
$cfrom :: forall x. UpdateRecords -> Rep UpdateRecords x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRecords' 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:
--
-- 'recordPatches', 'updateRecords_recordPatches' - A list of patch operations.
--
-- 'deviceId', 'updateRecords_deviceId' - The unique ID generated for this device by Cognito.
--
-- 'clientContext', 'updateRecords_clientContext' - Intended to supply a device ID that will populate the lastModifiedBy
-- field referenced in other methods. The ClientContext field is not yet
-- implemented.
--
-- 'identityPoolId', 'updateRecords_identityPoolId' - A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
--
-- 'identityId', 'updateRecords_identityId' - A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
--
-- 'datasetName', 'updateRecords_datasetName' - A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9,
-- \'_\' (underscore), \'-\' (dash), and \'.\' (dot).
--
-- 'syncSessionToken', 'updateRecords_syncSessionToken' - The SyncSessionToken returned by a previous call to ListRecords for this
-- dataset and identity.
newUpdateRecords ::
  -- | 'identityPoolId'
  Prelude.Text ->
  -- | 'identityId'
  Prelude.Text ->
  -- | 'datasetName'
  Prelude.Text ->
  -- | 'syncSessionToken'
  Prelude.Text ->
  UpdateRecords
newUpdateRecords :: Text -> Text -> Text -> Text -> UpdateRecords
newUpdateRecords
  Text
pIdentityPoolId_
  Text
pIdentityId_
  Text
pDatasetName_
  Text
pSyncSessionToken_ =
    UpdateRecords' :: Maybe [RecordPatch]
-> Maybe Text
-> Maybe Text
-> Text
-> Text
-> Text
-> Text
-> UpdateRecords
UpdateRecords'
      { $sel:recordPatches:UpdateRecords' :: Maybe [RecordPatch]
recordPatches = Maybe [RecordPatch]
forall a. Maybe a
Prelude.Nothing,
        $sel:deviceId:UpdateRecords' :: Maybe Text
deviceId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:clientContext:UpdateRecords' :: Maybe Text
clientContext = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:identityPoolId:UpdateRecords' :: Text
identityPoolId = Text
pIdentityPoolId_,
        $sel:identityId:UpdateRecords' :: Text
identityId = Text
pIdentityId_,
        $sel:datasetName:UpdateRecords' :: Text
datasetName = Text
pDatasetName_,
        $sel:syncSessionToken:UpdateRecords' :: Text
syncSessionToken = Text
pSyncSessionToken_
      }

-- | A list of patch operations.
updateRecords_recordPatches :: Lens.Lens' UpdateRecords (Prelude.Maybe [RecordPatch])
updateRecords_recordPatches :: (Maybe [RecordPatch] -> f (Maybe [RecordPatch]))
-> UpdateRecords -> f UpdateRecords
updateRecords_recordPatches = (UpdateRecords -> Maybe [RecordPatch])
-> (UpdateRecords -> Maybe [RecordPatch] -> UpdateRecords)
-> Lens
     UpdateRecords
     UpdateRecords
     (Maybe [RecordPatch])
     (Maybe [RecordPatch])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Maybe [RecordPatch]
recordPatches :: Maybe [RecordPatch]
$sel:recordPatches:UpdateRecords' :: UpdateRecords -> Maybe [RecordPatch]
recordPatches} -> Maybe [RecordPatch]
recordPatches) (\s :: UpdateRecords
s@UpdateRecords' {} Maybe [RecordPatch]
a -> UpdateRecords
s {$sel:recordPatches:UpdateRecords' :: Maybe [RecordPatch]
recordPatches = Maybe [RecordPatch]
a} :: UpdateRecords) ((Maybe [RecordPatch] -> f (Maybe [RecordPatch]))
 -> UpdateRecords -> f UpdateRecords)
-> ((Maybe [RecordPatch] -> f (Maybe [RecordPatch]))
    -> Maybe [RecordPatch] -> f (Maybe [RecordPatch]))
-> (Maybe [RecordPatch] -> f (Maybe [RecordPatch]))
-> UpdateRecords
-> f UpdateRecords
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [RecordPatch] [RecordPatch] [RecordPatch] [RecordPatch]
-> Iso
     (Maybe [RecordPatch])
     (Maybe [RecordPatch])
     (Maybe [RecordPatch])
     (Maybe [RecordPatch])
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 [RecordPatch] [RecordPatch] [RecordPatch] [RecordPatch]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The unique ID generated for this device by Cognito.
updateRecords_deviceId :: Lens.Lens' UpdateRecords (Prelude.Maybe Prelude.Text)
updateRecords_deviceId :: (Maybe Text -> f (Maybe Text)) -> UpdateRecords -> f UpdateRecords
updateRecords_deviceId = (UpdateRecords -> Maybe Text)
-> (UpdateRecords -> Maybe Text -> UpdateRecords)
-> Lens UpdateRecords UpdateRecords (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Maybe Text
deviceId :: Maybe Text
$sel:deviceId:UpdateRecords' :: UpdateRecords -> Maybe Text
deviceId} -> Maybe Text
deviceId) (\s :: UpdateRecords
s@UpdateRecords' {} Maybe Text
a -> UpdateRecords
s {$sel:deviceId:UpdateRecords' :: Maybe Text
deviceId = Maybe Text
a} :: UpdateRecords)

-- | Intended to supply a device ID that will populate the lastModifiedBy
-- field referenced in other methods. The ClientContext field is not yet
-- implemented.
updateRecords_clientContext :: Lens.Lens' UpdateRecords (Prelude.Maybe Prelude.Text)
updateRecords_clientContext :: (Maybe Text -> f (Maybe Text)) -> UpdateRecords -> f UpdateRecords
updateRecords_clientContext = (UpdateRecords -> Maybe Text)
-> (UpdateRecords -> Maybe Text -> UpdateRecords)
-> Lens UpdateRecords UpdateRecords (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Maybe Text
clientContext :: Maybe Text
$sel:clientContext:UpdateRecords' :: UpdateRecords -> Maybe Text
clientContext} -> Maybe Text
clientContext) (\s :: UpdateRecords
s@UpdateRecords' {} Maybe Text
a -> UpdateRecords
s {$sel:clientContext:UpdateRecords' :: Maybe Text
clientContext = Maybe Text
a} :: UpdateRecords)

-- | A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
updateRecords_identityPoolId :: Lens.Lens' UpdateRecords Prelude.Text
updateRecords_identityPoolId :: (Text -> f Text) -> UpdateRecords -> f UpdateRecords
updateRecords_identityPoolId = (UpdateRecords -> Text)
-> (UpdateRecords -> Text -> UpdateRecords)
-> Lens UpdateRecords UpdateRecords Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Text
identityPoolId :: Text
$sel:identityPoolId:UpdateRecords' :: UpdateRecords -> Text
identityPoolId} -> Text
identityPoolId) (\s :: UpdateRecords
s@UpdateRecords' {} Text
a -> UpdateRecords
s {$sel:identityPoolId:UpdateRecords' :: Text
identityPoolId = Text
a} :: UpdateRecords)

-- | A name-spaced GUID (for example,
-- us-east-1:23EC4050-6AEA-7089-A2DD-08002EXAMPLE) created by Amazon
-- Cognito. GUID generation is unique within a region.
updateRecords_identityId :: Lens.Lens' UpdateRecords Prelude.Text
updateRecords_identityId :: (Text -> f Text) -> UpdateRecords -> f UpdateRecords
updateRecords_identityId = (UpdateRecords -> Text)
-> (UpdateRecords -> Text -> UpdateRecords)
-> Lens UpdateRecords UpdateRecords Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Text
identityId :: Text
$sel:identityId:UpdateRecords' :: UpdateRecords -> Text
identityId} -> Text
identityId) (\s :: UpdateRecords
s@UpdateRecords' {} Text
a -> UpdateRecords
s {$sel:identityId:UpdateRecords' :: Text
identityId = Text
a} :: UpdateRecords)

-- | A string of up to 128 characters. Allowed characters are a-z, A-Z, 0-9,
-- \'_\' (underscore), \'-\' (dash), and \'.\' (dot).
updateRecords_datasetName :: Lens.Lens' UpdateRecords Prelude.Text
updateRecords_datasetName :: (Text -> f Text) -> UpdateRecords -> f UpdateRecords
updateRecords_datasetName = (UpdateRecords -> Text)
-> (UpdateRecords -> Text -> UpdateRecords)
-> Lens UpdateRecords UpdateRecords Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Text
datasetName :: Text
$sel:datasetName:UpdateRecords' :: UpdateRecords -> Text
datasetName} -> Text
datasetName) (\s :: UpdateRecords
s@UpdateRecords' {} Text
a -> UpdateRecords
s {$sel:datasetName:UpdateRecords' :: Text
datasetName = Text
a} :: UpdateRecords)

-- | The SyncSessionToken returned by a previous call to ListRecords for this
-- dataset and identity.
updateRecords_syncSessionToken :: Lens.Lens' UpdateRecords Prelude.Text
updateRecords_syncSessionToken :: (Text -> f Text) -> UpdateRecords -> f UpdateRecords
updateRecords_syncSessionToken = (UpdateRecords -> Text)
-> (UpdateRecords -> Text -> UpdateRecords)
-> Lens UpdateRecords UpdateRecords Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecords' {Text
syncSessionToken :: Text
$sel:syncSessionToken:UpdateRecords' :: UpdateRecords -> Text
syncSessionToken} -> Text
syncSessionToken) (\s :: UpdateRecords
s@UpdateRecords' {} Text
a -> UpdateRecords
s {$sel:syncSessionToken:UpdateRecords' :: Text
syncSessionToken = Text
a} :: UpdateRecords)

instance Core.AWSRequest UpdateRecords where
  type
    AWSResponse UpdateRecords =
      UpdateRecordsResponse
  request :: UpdateRecords -> Request UpdateRecords
request = Service -> UpdateRecords -> Request UpdateRecords
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRecords)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse UpdateRecords))
-> Logger
-> Service
-> Proxy UpdateRecords
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateRecords)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe [Record] -> Int -> UpdateRecordsResponse
UpdateRecordsResponse'
            (Maybe [Record] -> Int -> UpdateRecordsResponse)
-> Either String (Maybe [Record])
-> Either String (Int -> UpdateRecordsResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe (Maybe [Record]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"Records" Either String (Maybe (Maybe [Record]))
-> Maybe [Record] -> Either String (Maybe [Record])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Record]
forall a. Monoid a => a
Prelude.mempty)
            Either String (Int -> UpdateRecordsResponse)
-> Either String Int -> Either String UpdateRecordsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable UpdateRecords

instance Prelude.NFData UpdateRecords

instance Core.ToHeaders UpdateRecords where
  toHeaders :: UpdateRecords -> ResponseHeaders
toHeaders UpdateRecords' {Maybe [RecordPatch]
Maybe Text
Text
syncSessionToken :: Text
datasetName :: Text
identityId :: Text
identityPoolId :: Text
clientContext :: Maybe Text
deviceId :: Maybe Text
recordPatches :: Maybe [RecordPatch]
$sel:syncSessionToken:UpdateRecords' :: UpdateRecords -> Text
$sel:datasetName:UpdateRecords' :: UpdateRecords -> Text
$sel:identityId:UpdateRecords' :: UpdateRecords -> Text
$sel:identityPoolId:UpdateRecords' :: UpdateRecords -> Text
$sel:clientContext:UpdateRecords' :: UpdateRecords -> Maybe Text
$sel:deviceId:UpdateRecords' :: UpdateRecords -> Maybe Text
$sel:recordPatches:UpdateRecords' :: UpdateRecords -> Maybe [RecordPatch]
..} =
    [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"x-amz-Client-Context" HeaderName -> Maybe Text -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# Maybe Text
clientContext,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToJSON UpdateRecords where
  toJSON :: UpdateRecords -> Value
toJSON UpdateRecords' {Maybe [RecordPatch]
Maybe Text
Text
syncSessionToken :: Text
datasetName :: Text
identityId :: Text
identityPoolId :: Text
clientContext :: Maybe Text
deviceId :: Maybe Text
recordPatches :: Maybe [RecordPatch]
$sel:syncSessionToken:UpdateRecords' :: UpdateRecords -> Text
$sel:datasetName:UpdateRecords' :: UpdateRecords -> Text
$sel:identityId:UpdateRecords' :: UpdateRecords -> Text
$sel:identityPoolId:UpdateRecords' :: UpdateRecords -> Text
$sel:clientContext:UpdateRecords' :: UpdateRecords -> Maybe Text
$sel:deviceId:UpdateRecords' :: UpdateRecords -> Maybe Text
$sel:recordPatches:UpdateRecords' :: UpdateRecords -> Maybe [RecordPatch]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RecordPatches" Text -> [RecordPatch] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([RecordPatch] -> Pair) -> Maybe [RecordPatch] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [RecordPatch]
recordPatches,
            (Text
"DeviceId" 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
deviceId,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"SyncSessionToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
syncSessionToken)
          ]
      )

instance Core.ToPath UpdateRecords where
  toPath :: UpdateRecords -> ByteString
toPath UpdateRecords' {Maybe [RecordPatch]
Maybe Text
Text
syncSessionToken :: Text
datasetName :: Text
identityId :: Text
identityPoolId :: Text
clientContext :: Maybe Text
deviceId :: Maybe Text
recordPatches :: Maybe [RecordPatch]
$sel:syncSessionToken:UpdateRecords' :: UpdateRecords -> Text
$sel:datasetName:UpdateRecords' :: UpdateRecords -> Text
$sel:identityId:UpdateRecords' :: UpdateRecords -> Text
$sel:identityPoolId:UpdateRecords' :: UpdateRecords -> Text
$sel:clientContext:UpdateRecords' :: UpdateRecords -> Maybe Text
$sel:deviceId:UpdateRecords' :: UpdateRecords -> Maybe Text
$sel:recordPatches:UpdateRecords' :: UpdateRecords -> Maybe [RecordPatch]
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/identitypools/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
identityPoolId,
        ByteString
"/identities/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
identityId,
        ByteString
"/datasets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
datasetName
      ]

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

-- | Returned for a successful UpdateRecordsRequest.
--
-- /See:/ 'newUpdateRecordsResponse' smart constructor.
data UpdateRecordsResponse = UpdateRecordsResponse'
  { -- | A list of records that have been updated.
    UpdateRecordsResponse -> Maybe [Record]
records :: Prelude.Maybe [Record],
    -- | The response's http status code.
    UpdateRecordsResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (UpdateRecordsResponse -> UpdateRecordsResponse -> Bool
(UpdateRecordsResponse -> UpdateRecordsResponse -> Bool)
-> (UpdateRecordsResponse -> UpdateRecordsResponse -> Bool)
-> Eq UpdateRecordsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateRecordsResponse -> UpdateRecordsResponse -> Bool
$c/= :: UpdateRecordsResponse -> UpdateRecordsResponse -> Bool
== :: UpdateRecordsResponse -> UpdateRecordsResponse -> Bool
$c== :: UpdateRecordsResponse -> UpdateRecordsResponse -> Bool
Prelude.Eq, ReadPrec [UpdateRecordsResponse]
ReadPrec UpdateRecordsResponse
Int -> ReadS UpdateRecordsResponse
ReadS [UpdateRecordsResponse]
(Int -> ReadS UpdateRecordsResponse)
-> ReadS [UpdateRecordsResponse]
-> ReadPrec UpdateRecordsResponse
-> ReadPrec [UpdateRecordsResponse]
-> Read UpdateRecordsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateRecordsResponse]
$creadListPrec :: ReadPrec [UpdateRecordsResponse]
readPrec :: ReadPrec UpdateRecordsResponse
$creadPrec :: ReadPrec UpdateRecordsResponse
readList :: ReadS [UpdateRecordsResponse]
$creadList :: ReadS [UpdateRecordsResponse]
readsPrec :: Int -> ReadS UpdateRecordsResponse
$creadsPrec :: Int -> ReadS UpdateRecordsResponse
Prelude.Read, Int -> UpdateRecordsResponse -> ShowS
[UpdateRecordsResponse] -> ShowS
UpdateRecordsResponse -> String
(Int -> UpdateRecordsResponse -> ShowS)
-> (UpdateRecordsResponse -> String)
-> ([UpdateRecordsResponse] -> ShowS)
-> Show UpdateRecordsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateRecordsResponse] -> ShowS
$cshowList :: [UpdateRecordsResponse] -> ShowS
show :: UpdateRecordsResponse -> String
$cshow :: UpdateRecordsResponse -> String
showsPrec :: Int -> UpdateRecordsResponse -> ShowS
$cshowsPrec :: Int -> UpdateRecordsResponse -> ShowS
Prelude.Show, (forall x. UpdateRecordsResponse -> Rep UpdateRecordsResponse x)
-> (forall x. Rep UpdateRecordsResponse x -> UpdateRecordsResponse)
-> Generic UpdateRecordsResponse
forall x. Rep UpdateRecordsResponse x -> UpdateRecordsResponse
forall x. UpdateRecordsResponse -> Rep UpdateRecordsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateRecordsResponse x -> UpdateRecordsResponse
$cfrom :: forall x. UpdateRecordsResponse -> Rep UpdateRecordsResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateRecordsResponse' 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:
--
-- 'records', 'updateRecordsResponse_records' - A list of records that have been updated.
--
-- 'httpStatus', 'updateRecordsResponse_httpStatus' - The response's http status code.
newUpdateRecordsResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  UpdateRecordsResponse
newUpdateRecordsResponse :: Int -> UpdateRecordsResponse
newUpdateRecordsResponse Int
pHttpStatus_ =
  UpdateRecordsResponse' :: Maybe [Record] -> Int -> UpdateRecordsResponse
UpdateRecordsResponse'
    { $sel:records:UpdateRecordsResponse' :: Maybe [Record]
records = Maybe [Record]
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:UpdateRecordsResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A list of records that have been updated.
updateRecordsResponse_records :: Lens.Lens' UpdateRecordsResponse (Prelude.Maybe [Record])
updateRecordsResponse_records :: (Maybe [Record] -> f (Maybe [Record]))
-> UpdateRecordsResponse -> f UpdateRecordsResponse
updateRecordsResponse_records = (UpdateRecordsResponse -> Maybe [Record])
-> (UpdateRecordsResponse
    -> Maybe [Record] -> UpdateRecordsResponse)
-> Lens
     UpdateRecordsResponse
     UpdateRecordsResponse
     (Maybe [Record])
     (Maybe [Record])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecordsResponse' {Maybe [Record]
records :: Maybe [Record]
$sel:records:UpdateRecordsResponse' :: UpdateRecordsResponse -> Maybe [Record]
records} -> Maybe [Record]
records) (\s :: UpdateRecordsResponse
s@UpdateRecordsResponse' {} Maybe [Record]
a -> UpdateRecordsResponse
s {$sel:records:UpdateRecordsResponse' :: Maybe [Record]
records = Maybe [Record]
a} :: UpdateRecordsResponse) ((Maybe [Record] -> f (Maybe [Record]))
 -> UpdateRecordsResponse -> f UpdateRecordsResponse)
-> ((Maybe [Record] -> f (Maybe [Record]))
    -> Maybe [Record] -> f (Maybe [Record]))
-> (Maybe [Record] -> f (Maybe [Record]))
-> UpdateRecordsResponse
-> f UpdateRecordsResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Record] [Record] [Record] [Record]
-> Iso
     (Maybe [Record]) (Maybe [Record]) (Maybe [Record]) (Maybe [Record])
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 [Record] [Record] [Record] [Record]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The response's http status code.
updateRecordsResponse_httpStatus :: Lens.Lens' UpdateRecordsResponse Prelude.Int
updateRecordsResponse_httpStatus :: (Int -> f Int) -> UpdateRecordsResponse -> f UpdateRecordsResponse
updateRecordsResponse_httpStatus = (UpdateRecordsResponse -> Int)
-> (UpdateRecordsResponse -> Int -> UpdateRecordsResponse)
-> Lens UpdateRecordsResponse UpdateRecordsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateRecordsResponse' {Int
httpStatus :: Int
$sel:httpStatus:UpdateRecordsResponse' :: UpdateRecordsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: UpdateRecordsResponse
s@UpdateRecordsResponse' {} Int
a -> UpdateRecordsResponse
s {$sel:httpStatus:UpdateRecordsResponse' :: Int
httpStatus = Int
a} :: UpdateRecordsResponse)

instance Prelude.NFData UpdateRecordsResponse