コード例 #1
0
        private async Task UpdateTableAsync(IAmazonDynamoDB client, string authorizationTableName,
                                            List <GlobalSecondaryIndexUpdate> indexUpdates)
        {
            await client.UpdateTableAsync(new UpdateTableRequest
            {
                TableName = authorizationTableName,
                GlobalSecondaryIndexUpdates = indexUpdates
            });

            await DynamoUtils.WaitForActiveTableAsync(client, authorizationTableName);
        }
コード例 #2
0
        private async Task CreateTableAsync(IAmazonDynamoDB client, string tokenTableName,
                                            ProvisionedThroughput provisionedThroughput, List <GlobalSecondaryIndex> globalSecondaryIndexes)
        {
            var response = await client.CreateTableAsync(new CreateTableRequest
            {
                TableName             = tokenTableName,
                ProvisionedThroughput = provisionedThroughput,
                KeySchema             = new List <KeySchemaElement>
                {
                    new KeySchemaElement
                    {
                        AttributeName = "Id",
                        KeyType       = KeyType.HASH
                    }
                },
                AttributeDefinitions = new List <AttributeDefinition>
                {
                    new AttributeDefinition
                    {
                        AttributeName = "Id",
                        AttributeType = ScalarAttributeType.S
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Subject",
                        AttributeType = ScalarAttributeType.S
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Application",
                        AttributeType = ScalarAttributeType.S
                    },
                    new AttributeDefinition
                    {
                        AttributeName = "Authorization",
                        AttributeType = ScalarAttributeType.S
                    }
                },
                GlobalSecondaryIndexes = globalSecondaryIndexes
            });

            if (response.HttpStatusCode != HttpStatusCode.OK)
            {
                throw new Exception($"Couldn't create table {tokenTableName}");
            }

            await DynamoUtils.WaitForActiveTableAsync(client, tokenTableName);
        }