Skip to content

Commit

Permalink
Add @aws-lite/dynamodb methods: ImportTable, ListBackups, `List…
Browse files Browse the repository at this point in the history
…ContributorInsights`,

... `ListExports`, `ListGlobalTables`, `ListImports`, `ListTables`, `ListTagsOfResource`
Backfill debug method property
  • Loading branch information
ryanblock committed Sep 23, 2023
1 parent 9b6ebfc commit a558139
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 11 deletions.
103 changes: 93 additions & 10 deletions plugins/dynamodb/src/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -492,30 +492,113 @@ const GetItem = {
response: unmarshall(awsjsonRes),
}

// TODO:
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ImportTable.html
// ImportTable
const ImportTable = {
validate: {
InputFormat: { ...str, required },
S3BucketSource: { ...obj, required },
TableCreationParameters: { ...obj, required },
ClientToken: str,
InputCompressionType: str,
InputFormatOptions: obj,
},
request: async (params) => ({
headers: headers('ImportTable'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListBackups.html
// ListBackups
const ListBackups = {
validate: {
BackupType: str,
ExclusiveStartBackupArn: str,
Limit: num,
TableName: str,
TimeRangeLowerBound: num,
TimeRangeUpperBound: num,
},
request: async (params) => ({
headers: headers('ListBackups'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListContributorInsights.html
// ListContributorInsights
const ListContributorInsights = {
validate: {
MaxResults: num,
NextToken: str,
TableName: str,
},
request: async (params) => ({
headers: headers('ListContributorInsights'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListExports.html
// ListExports
const ListExports = {
validate: {
MaxResults: num,
NextToken: str,
TableArn: str,
},
request: async (params) => ({
headers: headers('ListExports'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListGlobalTables.html
// ListGlobalTables
const ListGlobalTables = {
validate: {
ExclusiveStartGlobalTableName: str,
Limit: num,
RegionName: str,
},
request: async (params) => ({
headers: headers('ListGlobalTables'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListImports.html
// ListImports
const ListImports = {
validate: {
NextToken: str,
PageSize: num,
TableArn: str,
},
request: async (params) => ({
headers: headers('ListImports'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTables.html
// ListTables
const ListTables = {
validate: {
ExclusiveStartTableName: str,
Limit: num,
},
request: async (params) => ({
headers: headers('ListTables'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_ListTagsOfResource.html
// ListTagsOfResource
const ListTagsOfResource = {
validate: {
NextToken: str,
ResourceArn: { ...str, required },
},
request: async (params) => ({
headers: headers('ListTagsOfResource'),
payload: params,
}),
}

// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_PutItem.html
const PutItem = {
Expand Down Expand Up @@ -589,5 +672,5 @@ const PutItem = {
// https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_UpdateTimeToLive.html
// UpdateTimeToLive

const methods = { BatchExecuteStatement, BatchGetItem, BatchWriteItem, CreateBackup, DeleteItem, DeleteTable, CreateGlobalTable, CreateTable, DeleteBackup, DescribeBackup, DescribeContinuousBackups, DescribeContributorInsights, DescribeEndpoints, DescribeExport, DescribeGlobalTable, DescribeGlobalTableSettings, DescribeImport, DescribeKinesisStreamingDestination, DescribeLimits, DescribeTable, DescribeTableReplicaAutoScaling, DescribeTimeToLive, DisableKinesisStreamingDestination, EnableKinesisStreamingDestination, ExecuteStatement, ExecuteTransaction, ExportTableToPointInTime, GetItem, PutItem }
const methods = { BatchExecuteStatement, BatchGetItem, BatchWriteItem, CreateBackup, DeleteItem, DeleteTable, CreateGlobalTable, CreateTable, DeleteBackup, DescribeBackup, DescribeContinuousBackups, DescribeContributorInsights, DescribeEndpoints, DescribeExport, DescribeGlobalTable, DescribeGlobalTableSettings, DescribeImport, DescribeKinesisStreamingDestination, DescribeLimits, DescribeTable, DescribeTableReplicaAutoScaling, DescribeTimeToLive, DisableKinesisStreamingDestination, EnableKinesisStreamingDestination, ExecuteStatement, ExecuteTransaction, ExportTableToPointInTime, GetItem, ImportTable, ListBackups, ListContributorInsights, ListExports, ListGlobalTables, ListImports, ListTables, ListTagsOfResource, PutItem }
export default { service, methods }
2 changes: 1 addition & 1 deletion src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ module.exports = function request (params, creds, region, config, metadata) {

/* istanbul ignore next */
if (config.debug) {
let { method, service, host, path, port = '', headers, protocol, body } = options
let { method = 'GET', service, host, path, port = '', headers, protocol, body } = options
let truncatedBody = body?.length > 1000 ? body?.substring(0, 1000) + '...' : body
console.error('[aws-lite] Requesting:', {
service,
Expand Down

0 comments on commit a558139

Please sign in to comment.