static void Main(string[] args) { var awsKey = "my-aws-key"; var awsSecret = "my-aws-secret"; var config = new AmazonDynamoDBConfig { ServiceURL = "http://localhost:8000" }; var client = new AmazonDynamoDBClient(awsKey, awsSecret, config); var ctx = new DynamoDBContext(client); var userId = "theburningmonk-1"; // query examples QueryByHashKey(userId, client, ctx); QueryWithRangeKey(userId, client, ctx); QueryWithOrderAndLimit(userId, client, ctx); QueryWithNoConsistentRead(userId, client, ctx); ThrottlingWithQueryPageSize(userId, client, ctx); SelectSpecificAttributes(userId, client, ctx); QueryWithNoReturnedConsumedCapacity(userId, client); QueryWithLocalSecondaryIndexAllAttributes(userId, client, ctx); QueryWithLocalSecondaryIndexProjectedAttributes(userId, client, ctx); QueryWithGlobalSecondaryIndexProjectedAttributes(client, ctx); // scan examples BasicScan(client, ctx); ScanWithLimit(client, ctx); ThrottlingWithScanPageSize(client, ctx); ScanWithScanPageSizeAndSegments(client, ctx); ScanWithNoReturnedConsumedCapacity(client); SelectSpecificAttributes(client, ctx); Console.WriteLine("all done..."); Console.ReadKey(); }
public AmazonDynamoDBClient ConnectAmazonDynamoDB(string ConnectionString) { var config = new AmazonDynamoDBConfig(); config.ServiceURL = ConnectionString; var client = new AmazonDynamoDBClient(config); return client; }
public DynamoDBSink(IFormatProvider formatProvider, string tableName) :base(1000, TimeSpan.FromSeconds(15)) { _formatProvider = formatProvider; _tableName = tableName; AmazonDynamoDbConfig = new AmazonDynamoDBConfig(); OperationConfig = new DynamoDBOperationConfig {OverrideTableName = tableName}; }
protected override void Load(ContainerBuilder builder) { var config = new AmazonDynamoDBConfig(); config.RegionEndpoint = Amazon.RegionEndpoint.APSoutheast2; var client = new AmazonDynamoDBClient(config); builder.Register(c => client).As<IAmazonDynamoDB>(); builder.RegisterType<SessionsRepository>().As<ISessionsRepository>(); }
static NotesDataContext() { // creating a DynamoDb client in some region (AmazonDynamoDBClient is thread-safe and can be reused var dynamoDbConfig = new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint.APSoutheast1 }; DynamoDbClient = new AmazonDynamoDBClient(dynamoDbConfig); // creating a MemcacheD client (it's thread-safe and can be reused) CacheClient = new MemcachedClient(); // creating tables CreateTablesIfTheyDoNotExist(); }
public Dictionary<string, object> GetPinWithPinID(string owner, double pinDate) { Dictionary<string, object> retval = new Dictionary<string, object>(); QueryResponse response; var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); try { QueryRequest request = new QueryRequest() { TableName = "Pin", KeyConditions = new Dictionary<string, Condition>() { { "Owner", new Condition() { ComparisonOperator = ComparisonOperator.EQ, AttributeValueList = new List<AttributeValue> { new AttributeValue { S = owner } } } }, { "PinDate", new Condition() { ComparisonOperator = ComparisonOperator.EQ, AttributeValueList = new List<AttributeValue> { new AttributeValue { N = pinDate.ToString() } } } } } }; response = client.Query(request); retval.Add("Title", response.Items[0]["Title"].S); retval.Add("Owner", response.Items[0]["Owner"].S); retval.Add("OwnerName", response.Items[0]["UserName"].S); retval.Add("OwnerHeadshot", response.Items[0]["HeadshotURL"].S); retval.Add("Latitude", response.Items[0]["Latitude"].S); retval.Add("Longitude", response.Items[0]["Longitude"].S); retval.Add("PinDate", Convert.ToDouble(response.Items[0]["PinDate"].N)); retval.Add("Images", response.Items[0]["Images"].SS); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } return retval; }
public bool CheckUserIsExist(string userID) { var config = new AmazonDynamoDBConfig(); GetItemResponse response; config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); bool retval = false; try { GetItemRequest request = new GetItemRequest { TableName = "User", Key = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = userID } } }, ReturnConsumedCapacity = "TOTAL" }; response = client.GetItem(request); retval = response.Item.Count > 0; } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } return retval; }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Access Key ID, AWS Secret Key and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="awsAccessKeyId">AWS Access Key ID</param> /// <param name="awsSecretAccessKey">AWS Secret Access Key</param> /// <param name="awsSessionToken">AWS Session Token</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonDynamoDBConfig clientConfig) : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session) { }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Credentials and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="credentials">AWS Credentials</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig clientConfig) : base(credentials, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session) { }
static void Main(string[] args) { var config = new AmazonDynamoDBConfig(); config.ServiceURL = "http://localhost:8000"; AmazonDynamoDBClient client = new AmazonDynamoDBClient(config); string tableName = "MonthlyTotals"; bool tableExists = false; string lastEvaluatedTableName = null; do { // Create a request object to specify optional parameters. var req = new ListTablesRequest { Limit = 10, // Page size. ExclusiveStartTableName = lastEvaluatedTableName }; var tblres = client.ListTables(req); foreach (string name in tblres.TableNames) { if (name.Equals(tableName)) { tableExists = true; break; } } if (tableExists) { break; } lastEvaluatedTableName = tblres.LastEvaluatedTableName; } while (lastEvaluatedTableName != null); if (!tableExists) { //Table doesnt exist, lets create it var request = new CreateTableRequest { TableName = tableName, AttributeDefinitions = new List<AttributeDefinition>() { new AttributeDefinition { AttributeName = "SKUId", AttributeType = "N" }, new AttributeDefinition { AttributeName = "Month", AttributeType = "S" } }, KeySchema = new List<KeySchemaElement>() { new KeySchemaElement { AttributeName = "SKUId", KeyType = "HASH" //Partition key }, new KeySchemaElement { AttributeName = "Month", KeyType = "RANGE" } }, ProvisionedThroughput = new ProvisionedThroughput { ReadCapacityUnits = 10, WriteCapacityUnits = 5 } }; CreateTableResponse response = client.CreateTable(request); var tableDescription = response.TableDescription; Console.WriteLine("{1}: {0} \t ReadCapacityUnits: {2} \t WriteCapacityUnits: {3}", tableDescription.TableStatus, tableDescription.TableName, tableDescription.ProvisionedThroughput.ReadCapacityUnits, tableDescription.ProvisionedThroughput.WriteCapacityUnits); string status = tableDescription.TableStatus; } var res = client.DescribeTable(new DescribeTableRequest { TableName = tableName }); Console.WriteLine(tableName + " - " + res.Table.TableStatus); Console.WriteLine(); Console.WriteLine("Test Crud?"); Console.ReadLine(); DynamoDBContext context = new DynamoDBContext(client); TestCRUDOperations(context); Console.ReadLine(); }
/// <summary> /// Create a client for the Amazon DynamoDB Service with the specified configuration /// </summary> /// <param name="awsAccessKey">The AWS Access Key associated with the account</param> /// <param name="awsSecretAccessKey">The AWS Secret Access Key associated with the account</param> /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc /// </param> /// <returns>An Amazon DynamoDB client</returns> /// <remarks> /// </remarks> public static IAmazonDynamoDB CreateAmazonDynamoDBClient( string awsAccessKey, string awsSecretAccessKey, AmazonDynamoDBConfig config ) { return new AmazonDynamoDBClient(awsAccessKey, awsSecretAccessKey, config); }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Access Key ID, AWS Secret Key and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="awsAccessKeyId">AWS Access Key ID</param> /// <param name="awsSecretAccessKey">AWS Secret Access Key</param> /// <param name="awsSessionToken">AWS Session Token</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonDynamoDBConfig clientConfig) : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig) { }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Access Key ID, AWS Secret Key and an /// AmazonDynamoDBClient Configuration object. If the config object's /// UseSecureStringForAwsSecretKey is false, the AWS Secret Key /// is stored as a clear-text string. Please use this option only /// if the application environment doesn't allow the use of SecureStrings. /// </summary> /// <param name="awsAccessKeyId">AWS Access Key ID</param> /// <param name="awsSecretAccessKey">AWS Secret Access Key</param> /// <param name="awsSessionToken">AWS Session Token</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonDynamoDBConfig clientConfig) : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig, AuthenticationTypes.User | AuthenticationTypes.Session) { }
/// <summary> /// Constructs AmazonDynamoDBClient with the credentials loaded from the application's /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance. /// /// Example App.config with credentials set. /// <code> /// <?xml version="1.0" encoding="utf-8" ?> /// <configuration> /// <appSettings> /// <add key="AWSAccessKey" value="********************"/> /// <add key="AWSSecretKey" value="****************************************"/> /// </appSettings> /// </configuration> /// </code> /// /// </summary> /// <param name="config">The AmazonDynamoDBv2 Configuration Object</param> public AmazonDynamoDBClient(AmazonDynamoDBConfig config) : base(FallbackCredentialsFactory.GetCredentials(), config, true, AuthenticationTypes.User | AuthenticationTypes.Session) { }
public bool InsertUser(Dictionary<string, object> us) { var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); try { PutItemRequest putReq = new PutItemRequest { TableName = "User", Item = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = us["userID"].ToString() } } , { "UserName", new AttributeValue { S = us["userName"].ToString() } } , { "HeadshotURL", new AttributeValue { S = us["headshotURL"].ToString() } } , { "IsPayUser", new AttributeValue { S = us["IsPayUser"].ToString() } } , { "RegistDate", new AttributeValue { N = us["registDate"].ToString() } } , { "LastLoginDate", new AttributeValue { N = us["lastLoginDate"].ToString() } } , { "LastSyncDate", new AttributeValue { N = us["lastSyncDate"].ToString() } } } }; PutItemResponse response = client.PutItem(putReq); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } //using (PinContext context = new PinContext(PinConnString)) //{ // context.Entry(us).State = EntityState.Added; // context.SaveChanges(); //} return true; }
public List<Dictionary<string, object>> GetPinWithUserIDs(List<string> userIDs, double since, int takeCnt) { List<Dictionary<string, object>> retval = new List<Dictionary<string, object>>(); Dictionary<string, object> tmpObject = null; var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); List<AttributeValue> users = new List<AttributeValue>(); foreach (string item in userIDs) { users.Add(new AttributeValue() { S = item }); } try { ScanRequest sreq = new ScanRequest() { TableName = "Pin", ScanFilter = new Dictionary<string, Condition>() { { "Owner", new Condition { ComparisonOperator = ComparisonOperator.IN, AttributeValueList = users } }, { "PinDate", new Condition() { ComparisonOperator = ComparisonOperator.LT, AttributeValueList = new List<AttributeValue> { new AttributeValue { N = since.ToString() } } } } } }; var response = client.Scan(sreq); foreach (var item in response.Items) { tmpObject = new Dictionary<string, object>(); tmpObject.Add("Title", item["Title"].S); tmpObject.Add("Owner", item["Owner"].S); tmpObject.Add("OwnerName", item["UserName"].S); tmpObject.Add("OwnerHeadshot", item["HeadshotURL"].S); tmpObject.Add("Latitude", item["Latitude"].S); tmpObject.Add("Longitude", item["Longitude"].S); tmpObject.Add("PinDate", Convert.ToDouble(item["PinDate"].N)); tmpObject.Add("Images", item["Images"].SS); retval.Add(tmpObject); } retval = retval.OrderByDescending(a => a["PinDate"]).ToList<Dictionary<string, object>>(); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } return retval; }
public Dictionary<string, object> GetUser(string userID) { Dictionary<string, object> retval = new Dictionary<string, object>(); GetItemResponse response; var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); try { GetItemRequest request = new GetItemRequest { TableName = "User", Key = new Dictionary<string, AttributeValue>() { { "UserID", new AttributeValue { S = userID } } }, ReturnConsumedCapacity = "TOTAL" }; response = client.GetItem(request); retval.Add("UserID", response.Item["UserID"].S); retval.Add("HeadshotURL", response.Item["HeadshotURL"].S); retval.Add("IsPayUser", Convert.ToBoolean(response.Item["IsPayUser"].S)); retval.Add("UserName", response.Item["UserName"].S); retval.Add("RegistDate", response.Item["RegistDate"].N); retval.Add("LastLoginDate", response.Item["LastLoginDate"].N); retval.Add("LastSyncDate", response.Item["LastSyncDate"].N); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } return retval; }
public List<Dictionary<string, object>> GetPinWithUserID(string userID, double since, int takeCnt) { List<Dictionary<string, object>> retval = new List<Dictionary<string, object>>(); Dictionary<string, object> tmpObject = null; QueryResponse response = null; var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); try { QueryRequest query = new QueryRequest() { TableName = "Pin", KeyConditions = new Dictionary<string, Condition>() { { "Owner", new Condition() { ComparisonOperator = ComparisonOperator.EQ, AttributeValueList = new List<AttributeValue> { new AttributeValue { S = userID } } } }, { "PinDate", new Condition() { ComparisonOperator = ComparisonOperator.LT, AttributeValueList = new List<AttributeValue> { new AttributeValue { N = since.ToString() } } } } }, Limit = takeCnt, ScanIndexForward = false }; response = client.Query(query); foreach (var item in response.Items) { tmpObject = new Dictionary<string, object>(); tmpObject.Add("Title", item["Title"].S); tmpObject.Add("Owner", item["Owner"].S); tmpObject.Add("OwnerName", item["UserName"].S); tmpObject.Add("OwnerHeadshot", item["HeadshotURL"].S); tmpObject.Add("Latitude", item["Latitude"].S); tmpObject.Add("Longitude", item["Longitude"].S); tmpObject.Add("PinDate", Convert.ToDouble(item["PinDate"].N)); tmpObject.Add("Images", item["Images"].SS); retval.Add(tmpObject); } } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } return retval; }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Access Key ID, AWS Secret Key and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="awsAccessKeyId">AWS Access Key ID</param> /// <param name="awsSecretAccessKey">AWS Secret Access Key</param> /// <param name="awsSessionToken">AWS Session Token</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(string awsAccessKeyId, string awsSecretAccessKey, string awsSessionToken, AmazonDynamoDBConfig clientConfig) : base(awsAccessKeyId, awsSecretAccessKey, awsSessionToken, clientConfig) { }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Credentials and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="credentials">AWS Credentials</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig clientConfig) : base(credentials, clientConfig) { }
public async Task DynamoDBTruncateErrorTest() { var config = new AmazonDynamoDBConfig { RegionEndpoint = RegionEndpoint.USEast1, LogResponse = true }; AmazonDynamoDBClient client = new AmazonDynamoDBClient(config); var tableName= await SetupTable(client); try { var table = Table.LoadTable(client, tableName); await InsertData(table, "445", _body); var body = await ReadData(table, "445"); Assert.Equal(_body, body); } finally { await DeleteTable(client, tableName); } }
public bool StorePin(Dictionary<string, object> pn) { var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); try { PutItemRequest putReq = new PutItemRequest { TableName = "Pin", Item = new Dictionary<string, AttributeValue>() { { "Owner", new AttributeValue { S = pn["OwnerID"].ToString() } } , { "Title", new AttributeValue { S = pn["Title"].ToString() } } , { "PinDate", new AttributeValue { N = pn["PinDate"].ToString() } } , { "Latitude", new AttributeValue { S = pn["Latitude"].ToString() } } , { "Longitude", new AttributeValue { S = pn["Longitude"].ToString() } } , { "Images", new AttributeValue { SS = (List<string>)pn["Images"] } } , { "HeadshotURL", new AttributeValue { S = pn["OwnerHeadshot"].ToString() } } , { "UserName", new AttributeValue { S = pn["OwnerName"].ToString() } } , { "LastSyncDate", new AttributeValue { N = pn["LastSyncDate"].ToString() } } } }; PutItemResponse response = client.PutItem(putReq); } catch (AmazonDynamoDBException e) { Console.WriteLine(e.Message); } catch (AmazonServiceException e) { Console.WriteLine(e.Message); } catch (Exception e) { Console.WriteLine(e.Message); } return true; }
/// <summary> /// Constructs AmazonDynamoDBClient with the credentials loaded from the application's /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance. /// /// Example App.config with credentials set. /// <code> /// <?xml version="1.0" encoding="utf-8" ?> /// <configuration> /// <appSettings> /// <add key="AWSProfileName" value="AWS Default"/> /// </appSettings> /// </configuration> /// </code> /// /// </summary> /// <param name="config">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(AmazonDynamoDBConfig config) : base(FallbackCredentialsFactory.GetCredentials(), config) { }
public static void Main(string[] args) { try { var config = new AmazonDynamoDBConfig(); config.ServiceURL = System.Configuration.ConfigurationManager.AppSettings["ServiceURL"]; client = new AmazonDynamoDBClient(config); // InsertData(); // GetData("5", "Test"); // DeleteData("5", "Test"); // InsertData1(); //DeleteData1(5); //GetData1(4); Update1(11); } catch (Exception ex) { } }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Credentials and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="credentials">AWS Credentials</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig clientConfig) : base(credentials, clientConfig, false, AuthenticationTypes.User | AuthenticationTypes.Session) { }
/// <summary> /// Create a client for the Amazon DynamoDB Service with the credentials loaded from the application's /// default configuration, and if unsuccessful from the Instance Profile service on an EC2 instance. /// /// Example App.config with credentials set. /// <code> /// <?xml version="1.0" encoding="utf-8" ?> /// <configuration> /// <appSettings> /// <add key="AWSAccessKey" value="********************"/> /// <add key="AWSSecretKey" value="****************************************"/> /// </appSettings> /// </configuration> /// </code> /// </summary> /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param> /// <returns>An Amazon DynamoDB client</returns> public static IAmazonDynamoDB CreateAmazonDynamoDBClient(AmazonDynamoDBConfig config) { return new AmazonDynamoDBClient(config); }
/// <summary> /// Constructs AmazonDynamoDBClient with AWS Credentials and an /// AmazonDynamoDBClient Configuration object. /// </summary> /// <param name="credentials">AWS Credentials</param> /// <param name="clientConfig">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig clientConfig) : base(credentials, clientConfig) { }
public DynamoController() { var config = new AmazonDynamoDBConfig(); config.ServiceURL = "https://dynamodb.eu-central-1.amazonaws.com/"; _client = new AmazonDynamoDBClient(ConfigurationManager.AppSettings["AWSAccessKey"], ConfigurationManager.AppSettings["AWSSecretAccessKey"], config); }
/// <summary> /// Initializes the provider by pulling the config info from the web.config and validate/create the DynamoDB table. /// If the table is being created this method will block until the table is active. /// </summary> /// <param name="name"></param> /// <param name="config"></param> public override void Initialize(string name, NameValueCollection config) { _logger.InfoFormat("Initialize : Initializing Session provider {0}", name); if (config == null) throw new ArgumentNullException("config"); base.Initialize(name, config); GetConfigSettings(config); RegionEndpoint region = null; if(!string.IsNullOrEmpty(this._regionName)) region = RegionEndpoint.GetBySystemName(this._regionName); AWSCredentials credentials = null; if (!string.IsNullOrEmpty(this._accessKey)) { credentials = new BasicAWSCredentials(this._accessKey, this._secretKey); } else if (!string.IsNullOrEmpty(this._profileName)) { if (string.IsNullOrEmpty(this._profilesLocation)) credentials = new StoredProfileAWSCredentials(this._profileName); else credentials = new StoredProfileAWSCredentials(this._profileName, this._profilesLocation); } AmazonDynamoDBConfig ddbConfig = new AmazonDynamoDBConfig(); if (region != null) ddbConfig.RegionEndpoint = region; if (!string.IsNullOrEmpty(this._serviceURL)) ddbConfig.ServiceURL = this._serviceURL; if (credentials != null) { this._ddbClient = new AmazonDynamoDBClient(credentials, ddbConfig); } else { this._ddbClient = new AmazonDynamoDBClient(ddbConfig); } ((AmazonDynamoDBClient)this._ddbClient).BeforeRequestEvent += DynamoDBSessionStateStore_BeforeRequestEvent; SetupTable(); }
/// <summary> /// Constructs AmazonDynamoDBClient with the CognitoAWSCredentials loaded /// from the AWSPrefab Editor variables /// </summary> /// <param name="config">The AmazonDynamoDBClient Configuration Object</param> public AmazonDynamoDBClient(AmazonDynamoDBConfig config) : base(FallbackCredentialsFactory.GetCredentials(), config, AuthenticationTypes.User | AuthenticationTypes.Session) { }
/// <summary> /// Create a client for the Amazon DynamoDB Service with AWSCredentials and an AmazonDynamoDB Configuration object. /// </summary> /// <param name="credentials">AWS Credentials</param> /// <param name="config">Configuration options for the service like HTTP Proxy, # of connections, etc</param> /// <returns>An Amazon DynamoDB client</returns> /// <remarks> /// </remarks> public static IAmazonDynamoDB CreateAmazonDynamoDBClient(AWSCredentials credentials, AmazonDynamoDBConfig config) { return new AmazonDynamoDBClient(credentials, config); }
public void TestLargeRetryCount() { var maxRetries = 1000; var maxMilliseconds = 1; ClientConfig config = new AmazonDynamoDBConfig(); config.MaxErrorRetry = 100; var coreRetryPolicy = new DefaultRetryPolicy(config) { MaxBackoffInMilliseconds = maxMilliseconds }; var ddbRetryPolicy = new DynamoDBRetryPolicy(config) { MaxBackoffInMilliseconds = maxMilliseconds }; var context = new ExecutionContext(new RequestContext(false), null); for (int i = 0; i < maxRetries; i++) { context.RequestContext.Retries = i; coreRetryPolicy.WaitBeforeRetry(context); ddbRetryPolicy.WaitBeforeRetry(context); } }