//
// Copyright 2014-2015 Amazon.com,
// Inc. or its affiliates. All Rights Reserved.
//
// SPDX-License-Identifier: Apache-2.0
//
using System;
using System.Collections;
using System.Collections.Generic;
namespace Amazon.CognitoSync.SyncManager
{
///
/// A local storage like a sqlite database on which we can invoke actions like creating a dataset, or record
///
public partial interface ILocalStorage : IDisposable
{
///
/// Create a dataset
///
/// Identity Id
/// Dataset name.
void CreateDataset(string identityId, string datasetName);
///
/// Retrieves the string value of a key in dataset. The value can be null
/// when the record doesn't exist or is marked as deleted.
///
/// string value of the record, or null if not present or deleted.
/// Identity identifier.
/// Dataset name.
/// record key.
string GetValue(string identityId, string datasetName, string key);
///
/// Puts the value of a key in dataset. If a new value is assigned to the
/// key, the record is marked as dirty. If the value is null, then the record
/// is marked as deleted. The changed record will be synced with remote
/// storage.
///
/// Identity identifier.
/// Dataset name.
/// record key.
/// string value. If null, the record is marked as deleted.
void PutValue(string identityId, string datasetName, string key, string value);
///
/// Retrieves a key-value map from dataset, excluding marked as deleted
/// values.
///
/// a key-value map of all but deleted values.
/// Identity identifier.
/// Dataset name.
Dictionary GetValueMap(string identityId, string datasetName);
///
/// Puts a key-value map into a dataset. This is optimized for batch
/// operation. It's the preferred way to put a list of records into dataset.
///
/// Identity identifier.
/// Dataset name.
/// a key-value map.
void PutAllValues(string identityId, string datasetName, IDictionary values);
///
/// Gets a raw record from local store. If the dataset/key combo doesn't
/// // exist, null will be returned.
///
/// a Record object if found, null otherwise.
/// Identity identifier.
/// Dataset name.
/// Key for the record.
Record GetRecord(string identityId, string datasetName, string key);
///
/// Gets a list of all records.
///
/// A list of records which have been updated since lastSyncCount.
/// Identity identifier.
/// Dataset name.
List GetRecords(string identityId, string datasetName);
///
/// Retrieves a list of locally modified records since last successful sync
/// operation.
///
/// a list of locally modified records
/// Identity identifier.
/// Dataset name.
List GetModifiedRecords(string identityId, string datasetName);
///
/// Puts a list of raw records into dataset.
///
/// Identity identifier.
/// Dataset name.
/// A list of Records.
void PutRecords(string identityId, string datasetName, List records);
///
/// Puts a list of raw records into that dataset if
/// the local version hasn't changed (to be used in
/// synchronizations).
///
/// Identity id.
/// Dataset name.
/// A list of remote records to compare with
/// A list of records to check for changes.
void ConditionallyPutRecords(String identityId, String datasetName,List records, List localRecords);
///
/// Gets a list of dataset's metadata information.
///
/// a list of dataset metadata
/// Identity identifier.
///
List GetDatasetMetadata(string identityId);
///
/// Deletes a dataset. It clears all records in this dataset and marked it as
/// deleted for future sync.
///
/// Identity identifier.
/// Dataset name.
///
void DeleteDataset(string identityId, string datasetName);
///
/// This is different from . Not only does it
/// clears all records in the dataset, it also remove it from metadata table.
/// It won't be visible in .
///
/// Identity identifier.
/// Dataset name.
void PurgeDataset(string identityId, string datasetName);
///
/// Retrieves the metadata of a dataset.
///
/// The dataset metadata.
/// Identity identifier.
/// Dataset name.
///
DatasetMetadata GetDatasetMetadata(string identityId, string datasetName);
///
/// Retrieves the last sync count. This sync count is a counter that
/// represents when the last sync happened. The counter should be updated on
/// a successful sync.
///
/// The last sync count.
/// Identity identifier.
/// Dataset name.
long GetLastSyncCount(string identityId, string datasetName);
///
/// Updates the last sync count after successful sync with the remote data
/// store.
///
/// Identity identifier.
/// Dataset name.
/// Last sync count.
void UpdateLastSyncCount(string identityId, string datasetName, long lastSyncCount);
///
/// Wipes all locally cached data including dataset metadata and records. All
/// opened dataset handler should not perform further operations to avoid
/// inconsistent state.
///
void WipeData();
///
/// Reparents all datasets from old identity id to a new one.
///
/// Old identity identifier.
/// New identity identifier.
void ChangeIdentityId(string oldIdentityId, string newIdentityId);
///
/// Updates local dataset metadata
///
/// Identity identifier.
/// Dataset metadata.
void UpdateDatasetMetadata(string identityId, List datasetMetadata);
}
}