embulk-input-dynamodb 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/master.yml +34 -0
- data/.github/workflows/test.yml +30 -0
- data/.scalafmt.conf +5 -0
- data/CHANGELOG.md +49 -0
- data/README.md +204 -54
- data/build.gradle +53 -44
- data/example/config-deprecated.yml +20 -0
- data/example/config-query-as-json.yml +18 -0
- data/example/config-query.yml +22 -0
- data/example/config-scan.yml +18 -0
- data/example/prepare_dynamodb_table.sh +67 -0
- data/gradle/wrapper/gradle-wrapper.jar +0 -0
- data/gradle/wrapper/gradle-wrapper.properties +1 -2
- data/gradlew +67 -48
- data/gradlew.bat +20 -10
- data/{test/run_dynamodb_local.sh → run_dynamodb_local.sh} +2 -1
- data/settings.gradle +1 -0
- data/src/main/scala/org/embulk/input/dynamodb/DeprecatedDynamodbInputPlugin.scala +73 -0
- data/src/main/scala/org/embulk/input/dynamodb/DynamodbInputPlugin.scala +76 -25
- data/src/main/scala/org/embulk/input/dynamodb/PluginTask.scala +132 -32
- data/src/main/scala/org/embulk/input/dynamodb/aws/Aws.scala +44 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsClientConfiguration.scala +37 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsCredentials.scala +240 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsDynamodbConfiguration.scala +35 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/AwsEndpointConfiguration.scala +79 -0
- data/src/main/scala/org/embulk/input/dynamodb/aws/HttpProxy.scala +61 -0
- data/src/main/scala/org/embulk/input/dynamodb/deprecated/AttributeValueHelper.scala +72 -0
- data/src/main/scala/org/embulk/input/dynamodb/{Filter.scala → deprecated/Filter.scala} +3 -3
- data/src/main/scala/org/embulk/input/dynamodb/{FilterConfig.scala → deprecated/FilterConfig.scala} +13 -13
- data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/AbstractOperation.scala +36 -18
- data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/QueryOperation.scala +21 -13
- data/src/main/scala/org/embulk/input/dynamodb/{ope → deprecated/ope}/ScanOperation.scala +20 -13
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValue.scala +154 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValueEmbulkTypeTransformable.scala +245 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbAttributeValueType.scala +33 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemColumnVisitor.scala +50 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemConsumer.scala +40 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemIterator.scala +19 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemReader.scala +64 -0
- data/src/main/scala/org/embulk/input/dynamodb/item/DynamodbItemSchema.scala +135 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/AbstractDynamodbOperation.scala +169 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbOperationProxy.scala +59 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbQueryOperation.scala +72 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/DynamodbScanOperation.scala +93 -0
- data/src/main/scala/org/embulk/input/dynamodb/operation/EmbulkDynamodbOperation.scala +15 -0
- data/src/main/scala/org/embulk/input/dynamodb/package.scala +4 -9
- data/src/test/scala/org/embulk/input/dynamodb/AttributeValueHelperTest.scala +245 -101
- data/src/test/scala/org/embulk/input/dynamodb/AwsCredentialsTest.scala +150 -97
- data/src/test/scala/org/embulk/input/dynamodb/DynamodbQueryOperationTest.scala +188 -0
- data/src/test/scala/org/embulk/input/dynamodb/DynamodbScanOperationTest.scala +181 -0
- data/src/test/scala/org/embulk/input/dynamodb/testutil/EmbulkTestBase.scala +85 -0
- metadata +73 -49
- data/circle.yml +0 -16
- data/config/checkstyle/checkstyle.xml +0 -128
- data/config/checkstyle/default.xml +0 -108
- data/src/main/scala/org/embulk/input/dynamodb/AttributeValueHelper.scala +0 -41
- data/src/main/scala/org/embulk/input/dynamodb/AwsCredentials.scala +0 -63
- data/src/main/scala/org/embulk/input/dynamodb/DynamoDBClient.scala +0 -23
- data/src/test/resources/yaml/authMethodBasic.yml +0 -21
- data/src/test/resources/yaml/authMethodBasic_Error.yml +0 -19
- data/src/test/resources/yaml/authMethodEnv.yml +0 -19
- data/src/test/resources/yaml/authMethodProfile.yml +0 -20
- data/src/test/resources/yaml/dynamodb-local-query.yml +0 -25
- data/src/test/resources/yaml/dynamodb-local-scan.yml +0 -23
- data/src/test/resources/yaml/notSetAuthMethod.yml +0 -20
- data/src/test/scala/org/embulk/input/dynamodb/ope/QueryOperationTest.scala +0 -83
- data/src/test/scala/org/embulk/input/dynamodb/ope/ScanOperationTest.scala +0 -83
- data/test/create_table.sh +0 -16
- data/test/put_items.sh +0 -25
data/circle.yml
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
machine:
|
2
|
-
services:
|
3
|
-
- docker
|
4
|
-
|
5
|
-
general:
|
6
|
-
artifacts:
|
7
|
-
- "~/embulk-input-dynamodb/build/reports/tests"
|
8
|
-
|
9
|
-
test:
|
10
|
-
pre:
|
11
|
-
- sh ./test/run_dynamodb_local.sh; sleep 2
|
12
|
-
- sh ./test/create_table.sh
|
13
|
-
- sh ./test/put_items.sh
|
14
|
-
post:
|
15
|
-
- mkdir -p $CIRCLE_TEST_REPORTS/junit/
|
16
|
-
- find . -type f -regex ".*/test-results/*/.*xml" -exec cp {} $CIRCLE_TEST_REPORTS/junit/ \;
|
@@ -1,128 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE module PUBLIC
|
3
|
-
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
-
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
-
<module name="Checker">
|
6
|
-
<!-- https://github.com/facebook/presto/blob/master/src/checkstyle/checks.xml -->
|
7
|
-
<module name="FileTabCharacter"/>
|
8
|
-
<module name="NewlineAtEndOfFile">
|
9
|
-
<property name="lineSeparator" value="lf"/>
|
10
|
-
</module>
|
11
|
-
<module name="RegexpMultiline">
|
12
|
-
<property name="format" value="\r"/>
|
13
|
-
<property name="message" value="Line contains carriage return"/>
|
14
|
-
</module>
|
15
|
-
<module name="RegexpMultiline">
|
16
|
-
<property name="format" value=" \n"/>
|
17
|
-
<property name="message" value="Line has trailing whitespace"/>
|
18
|
-
</module>
|
19
|
-
<module name="RegexpMultiline">
|
20
|
-
<property name="format" value="\{\n\n"/>
|
21
|
-
<property name="message" value="Blank line after opening brace"/>
|
22
|
-
</module>
|
23
|
-
<module name="RegexpMultiline">
|
24
|
-
<property name="format" value="\n\n\s*\}"/>
|
25
|
-
<property name="message" value="Blank line before closing brace"/>
|
26
|
-
</module>
|
27
|
-
<module name="RegexpMultiline">
|
28
|
-
<property name="format" value="\n\n\n"/>
|
29
|
-
<property name="message" value="Multiple consecutive blank lines"/>
|
30
|
-
</module>
|
31
|
-
<module name="RegexpMultiline">
|
32
|
-
<property name="format" value="\n\n\Z"/>
|
33
|
-
<property name="message" value="Blank line before end of file"/>
|
34
|
-
</module>
|
35
|
-
<module name="RegexpMultiline">
|
36
|
-
<property name="format" value="Preconditions\.checkNotNull"/>
|
37
|
-
<property name="message" value="Use of checkNotNull"/>
|
38
|
-
</module>
|
39
|
-
|
40
|
-
<module name="TreeWalker">
|
41
|
-
<module name="EmptyBlock">
|
42
|
-
<property name="option" value="text"/>
|
43
|
-
<property name="tokens" value="
|
44
|
-
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
45
|
-
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
46
|
-
</module>
|
47
|
-
<module name="EmptyStatement"/>
|
48
|
-
<module name="EmptyForInitializerPad"/>
|
49
|
-
<module name="EmptyForIteratorPad">
|
50
|
-
<property name="option" value="space"/>
|
51
|
-
</module>
|
52
|
-
<module name="MethodParamPad">
|
53
|
-
<property name="allowLineBreaks" value="true"/>
|
54
|
-
<property name="option" value="nospace"/>
|
55
|
-
</module>
|
56
|
-
<module name="ParenPad"/>
|
57
|
-
<module name="TypecastParenPad"/>
|
58
|
-
<module name="NeedBraces"/>
|
59
|
-
<module name="LeftCurly">
|
60
|
-
<property name="option" value="nl"/>
|
61
|
-
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
62
|
-
</module>
|
63
|
-
<module name="LeftCurly">
|
64
|
-
<property name="option" value="eol"/>
|
65
|
-
<property name="tokens" value="
|
66
|
-
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
67
|
-
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
68
|
-
</module>
|
69
|
-
<module name="RightCurly">
|
70
|
-
<property name="option" value="alone"/>
|
71
|
-
</module>
|
72
|
-
<module name="GenericWhitespace"/>
|
73
|
-
<module name="WhitespaceAfter"/>
|
74
|
-
<module name="NoWhitespaceBefore"/>
|
75
|
-
|
76
|
-
<module name="UpperEll"/>
|
77
|
-
<module name="DefaultComesLast"/>
|
78
|
-
<module name="ArrayTypeStyle"/>
|
79
|
-
<module name="MultipleVariableDeclarations"/>
|
80
|
-
<module name="ModifierOrder"/>
|
81
|
-
<module name="OneStatementPerLine"/>
|
82
|
-
<module name="StringLiteralEquality"/>
|
83
|
-
<module name="MutableException"/>
|
84
|
-
<module name="EqualsHashCode"/>
|
85
|
-
<module name="InnerAssignment"/>
|
86
|
-
<module name="InterfaceIsType"/>
|
87
|
-
<module name="HideUtilityClassConstructor"/>
|
88
|
-
|
89
|
-
<module name="MemberName"/>
|
90
|
-
<module name="LocalVariableName"/>
|
91
|
-
<module name="LocalFinalVariableName"/>
|
92
|
-
<module name="TypeName"/>
|
93
|
-
<module name="PackageName"/>
|
94
|
-
<module name="ParameterName"/>
|
95
|
-
<module name="StaticVariableName"/>
|
96
|
-
<module name="ClassTypeParameterName">
|
97
|
-
<property name="format" value="^[A-Z][0-9]?$"/>
|
98
|
-
</module>
|
99
|
-
<module name="MethodTypeParameterName">
|
100
|
-
<property name="format" value="^[A-Z][0-9]?$"/>
|
101
|
-
</module>
|
102
|
-
|
103
|
-
<module name="AvoidStarImport"/>
|
104
|
-
<module name="RedundantImport"/>
|
105
|
-
<module name="UnusedImports"/>
|
106
|
-
<module name="ImportOrder">
|
107
|
-
<property name="groups" value="*,javax,java"/>
|
108
|
-
<property name="separated" value="true"/>
|
109
|
-
<property name="option" value="bottom"/>
|
110
|
-
<property name="sortStaticImportsAlphabetically" value="true"/>
|
111
|
-
</module>
|
112
|
-
|
113
|
-
<module name="WhitespaceAround">
|
114
|
-
<property name="allowEmptyConstructors" value="true"/>
|
115
|
-
<property name="allowEmptyMethods" value="true"/>
|
116
|
-
<property name="ignoreEnhancedForColon" value="false"/>
|
117
|
-
<property name="tokens" value="
|
118
|
-
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
119
|
-
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
120
|
-
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
121
|
-
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
122
|
-
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
123
|
-
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
124
|
-
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
125
|
-
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
126
|
-
</module>
|
127
|
-
</module>
|
128
|
-
</module>
|
@@ -1,108 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<!DOCTYPE module PUBLIC
|
3
|
-
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
4
|
-
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
5
|
-
<!--
|
6
|
-
This is a subset of ./checkstyle.xml which allows some loose styles
|
7
|
-
-->
|
8
|
-
<module name="Checker">
|
9
|
-
<module name="FileTabCharacter"/>
|
10
|
-
<module name="NewlineAtEndOfFile">
|
11
|
-
<property name="lineSeparator" value="lf"/>
|
12
|
-
</module>
|
13
|
-
<module name="RegexpMultiline">
|
14
|
-
<property name="format" value="\r"/>
|
15
|
-
<property name="message" value="Line contains carriage return"/>
|
16
|
-
</module>
|
17
|
-
<module name="RegexpMultiline">
|
18
|
-
<property name="format" value=" \n"/>
|
19
|
-
<property name="message" value="Line has trailing whitespace"/>
|
20
|
-
</module>
|
21
|
-
<module name="RegexpMultiline">
|
22
|
-
<property name="format" value="\n\n\n"/>
|
23
|
-
<property name="message" value="Multiple consecutive blank lines"/>
|
24
|
-
</module>
|
25
|
-
<module name="RegexpMultiline">
|
26
|
-
<property name="format" value="\n\n\Z"/>
|
27
|
-
<property name="message" value="Blank line before end of file"/>
|
28
|
-
</module>
|
29
|
-
|
30
|
-
<module name="TreeWalker">
|
31
|
-
<module name="EmptyBlock">
|
32
|
-
<property name="option" value="text"/>
|
33
|
-
<property name="tokens" value="
|
34
|
-
LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_IF,
|
35
|
-
LITERAL_FOR, LITERAL_TRY, LITERAL_WHILE, INSTANCE_INIT, STATIC_INIT"/>
|
36
|
-
</module>
|
37
|
-
<module name="EmptyStatement"/>
|
38
|
-
<module name="EmptyForInitializerPad"/>
|
39
|
-
<module name="EmptyForIteratorPad">
|
40
|
-
<property name="option" value="space"/>
|
41
|
-
</module>
|
42
|
-
<module name="MethodParamPad">
|
43
|
-
<property name="allowLineBreaks" value="true"/>
|
44
|
-
<property name="option" value="nospace"/>
|
45
|
-
</module>
|
46
|
-
<module name="ParenPad"/>
|
47
|
-
<module name="TypecastParenPad"/>
|
48
|
-
<module name="NeedBraces"/>
|
49
|
-
<module name="LeftCurly">
|
50
|
-
<property name="option" value="nl"/>
|
51
|
-
<property name="tokens" value="CLASS_DEF, CTOR_DEF, INTERFACE_DEF, METHOD_DEF"/>
|
52
|
-
</module>
|
53
|
-
<module name="LeftCurly">
|
54
|
-
<property name="option" value="eol"/>
|
55
|
-
<property name="tokens" value="
|
56
|
-
LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE, LITERAL_FINALLY, LITERAL_FOR,
|
57
|
-
LITERAL_IF, LITERAL_SWITCH, LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE"/>
|
58
|
-
</module>
|
59
|
-
<module name="RightCurly">
|
60
|
-
<property name="option" value="alone"/>
|
61
|
-
</module>
|
62
|
-
<module name="GenericWhitespace"/>
|
63
|
-
<module name="WhitespaceAfter"/>
|
64
|
-
<module name="NoWhitespaceBefore"/>
|
65
|
-
|
66
|
-
<module name="UpperEll"/>
|
67
|
-
<module name="DefaultComesLast"/>
|
68
|
-
<module name="ArrayTypeStyle"/>
|
69
|
-
<module name="MultipleVariableDeclarations"/>
|
70
|
-
<module name="ModifierOrder"/>
|
71
|
-
<module name="OneStatementPerLine"/>
|
72
|
-
<module name="StringLiteralEquality"/>
|
73
|
-
<module name="MutableException"/>
|
74
|
-
<module name="EqualsHashCode"/>
|
75
|
-
<module name="InnerAssignment"/>
|
76
|
-
<module name="InterfaceIsType"/>
|
77
|
-
<module name="HideUtilityClassConstructor"/>
|
78
|
-
|
79
|
-
<module name="MemberName"/>
|
80
|
-
<module name="LocalVariableName"/>
|
81
|
-
<module name="LocalFinalVariableName"/>
|
82
|
-
<module name="TypeName"/>
|
83
|
-
<module name="PackageName"/>
|
84
|
-
<module name="ParameterName"/>
|
85
|
-
<module name="StaticVariableName"/>
|
86
|
-
<module name="ClassTypeParameterName">
|
87
|
-
<property name="format" value="^[A-Z][0-9]?$"/>
|
88
|
-
</module>
|
89
|
-
<module name="MethodTypeParameterName">
|
90
|
-
<property name="format" value="^[A-Z][0-9]?$"/>
|
91
|
-
</module>
|
92
|
-
|
93
|
-
<module name="WhitespaceAround">
|
94
|
-
<property name="allowEmptyConstructors" value="true"/>
|
95
|
-
<property name="allowEmptyMethods" value="true"/>
|
96
|
-
<property name="ignoreEnhancedForColon" value="false"/>
|
97
|
-
<property name="tokens" value="
|
98
|
-
ASSIGN, BAND, BAND_ASSIGN, BOR, BOR_ASSIGN, BSR, BSR_ASSIGN,
|
99
|
-
BXOR, BXOR_ASSIGN, COLON, DIV, DIV_ASSIGN, EQUAL, GE, GT, LAND, LE,
|
100
|
-
LITERAL_ASSERT, LITERAL_CATCH, LITERAL_DO, LITERAL_ELSE,
|
101
|
-
LITERAL_FINALLY, LITERAL_FOR, LITERAL_IF, LITERAL_RETURN,
|
102
|
-
LITERAL_SYNCHRONIZED, LITERAL_TRY, LITERAL_WHILE,
|
103
|
-
LOR, LT, MINUS, MINUS_ASSIGN, MOD, MOD_ASSIGN, NOT_EQUAL,
|
104
|
-
PLUS, PLUS_ASSIGN, QUESTION, SL, SLIST, SL_ASSIGN, SR, SR_ASSIGN,
|
105
|
-
STAR, STAR_ASSIGN, TYPE_EXTENSION_AND"/>
|
106
|
-
</module>
|
107
|
-
</module>
|
108
|
-
</module>
|
@@ -1,41 +0,0 @@
|
|
1
|
-
package org.embulk.input.dynamodb
|
2
|
-
|
3
|
-
import com.amazonaws.services.dynamodbv2.model.AttributeValue
|
4
|
-
import org.msgpack.value.{Value, ValueFactory}
|
5
|
-
|
6
|
-
import scala.util.Try
|
7
|
-
|
8
|
-
object AttributeValueHelper {
|
9
|
-
|
10
|
-
// referring aws-scala
|
11
|
-
def decodeToValue(value: AttributeValue): Value = {
|
12
|
-
import scala.collection.JavaConverters._
|
13
|
-
|
14
|
-
// FIXME: Need Encode?
|
15
|
-
lazy val _bin = Option(value.getB).map(v => ValueFactory.newBinary(v.array))
|
16
|
-
lazy val _bool = Option(value.getBOOL).map(v => ValueFactory.newBoolean(v))
|
17
|
-
lazy val _num = Option(value.getN).map(v =>
|
18
|
-
Try(v.toLong).map(ValueFactory.newInteger).getOrElse(ValueFactory.newFloat(v.toDouble)))
|
19
|
-
lazy val _str = Option(value.getS).map(v => ValueFactory.newString(v))
|
20
|
-
lazy val _nil = Option(value.getNULL).map(v => ValueFactory.newNil)
|
21
|
-
|
22
|
-
lazy val _list = Option(value.getL).map(l =>
|
23
|
-
ValueFactory.newArray(l.asScala.map(v => decodeToValue(v)).asJava))
|
24
|
-
lazy val _ss = Option(value.getSS).map(l =>
|
25
|
-
ValueFactory.newArray(l.asScala.map(v => ValueFactory.newString(v)).asJava))
|
26
|
-
lazy val _ns = Option(value.getNS).map(l =>
|
27
|
-
ValueFactory.newArray(l.asScala.map(v =>
|
28
|
-
Try(v.toLong).map(ValueFactory.newInteger).getOrElse(ValueFactory.newFloat(v.toDouble))).asJava))
|
29
|
-
// FIXME: Need Encode?
|
30
|
-
lazy val _bs = Option(value.getBS).map(l =>
|
31
|
-
ValueFactory.newArray(l.asScala.map(v => ValueFactory.newBinary(v.array)).asJava))
|
32
|
-
lazy val _map = Option(value.getM).map(m =>
|
33
|
-
ValueFactory.newMap(m.asScala.map(v => ValueFactory.newString(v._1) -> decodeToValue(v._2)).asJava))
|
34
|
-
|
35
|
-
_bin.orElse(_bool).orElse(_num).orElse(_str).orElse(_nil)
|
36
|
-
.orElse(_list).orElse(_ss).orElse(_ns).orElse(_bs).orElse(_map) match {
|
37
|
-
case None => ValueFactory.newNil
|
38
|
-
case Some(j) => j
|
39
|
-
}
|
40
|
-
}
|
41
|
-
}
|
@@ -1,63 +0,0 @@
|
|
1
|
-
package org.embulk.input.dynamodb
|
2
|
-
|
3
|
-
import com.amazonaws.auth._
|
4
|
-
import com.amazonaws.auth.profile.ProfileCredentialsProvider
|
5
|
-
import com.google.common.base.Optional
|
6
|
-
import org.embulk.config.ConfigException
|
7
|
-
|
8
|
-
object AwsCredentials {
|
9
|
-
def getCredentialsProvider(task: PluginTask): AWSCredentialsProvider = {
|
10
|
-
if (!task.getAuthMethod.isPresent) {
|
11
|
-
// backward compatibility
|
12
|
-
if (task.getAccessKey.isPresent && task.getSecretKey.isPresent) {
|
13
|
-
new AWSCredentialsProvider {
|
14
|
-
override def refresh(): Unit = {}
|
15
|
-
|
16
|
-
override def getCredentials: AWSCredentials = {
|
17
|
-
new BasicAWSCredentials(
|
18
|
-
task.getAccessKey.get(),
|
19
|
-
task.getSecretKey.get())
|
20
|
-
}
|
21
|
-
}
|
22
|
-
} else {
|
23
|
-
new ProfileCredentialsProvider()
|
24
|
-
}
|
25
|
-
} else {
|
26
|
-
val cred = task.getAuthMethod.get() match {
|
27
|
-
case "basic" =>
|
28
|
-
val accessKey = require(task.getAccessKey, "'access_key'")
|
29
|
-
val secretKey = require(task.getSecretKey, "'secret_key'")
|
30
|
-
|
31
|
-
new BasicAWSCredentials(accessKey, secretKey)
|
32
|
-
|
33
|
-
case "env" =>
|
34
|
-
new EnvironmentVariableCredentialsProvider().getCredentials
|
35
|
-
|
36
|
-
case "instance" =>
|
37
|
-
new InstanceProfileCredentialsProvider().getCredentials
|
38
|
-
|
39
|
-
case "profile" =>
|
40
|
-
val profileName = task.getProfileName.or("default")
|
41
|
-
|
42
|
-
try {
|
43
|
-
new ProfileCredentialsProvider(profileName).getCredentials
|
44
|
-
} catch {
|
45
|
-
case e: IllegalArgumentException =>
|
46
|
-
throw new ConfigException(s"No AWS profile named $profileName")
|
47
|
-
}
|
48
|
-
|
49
|
-
case "properties" =>
|
50
|
-
new SystemPropertiesCredentialsProvider().getCredentials
|
51
|
-
|
52
|
-
case _ =>
|
53
|
-
throw new ConfigException(s"Unknown 'auth_method' ${task.getAuthMethod.get()}")
|
54
|
-
}
|
55
|
-
|
56
|
-
new AWSCredentialsProvider {
|
57
|
-
override def refresh(): Unit = {}
|
58
|
-
|
59
|
-
override def getCredentials: AWSCredentials = { cred }
|
60
|
-
}
|
61
|
-
}
|
62
|
-
}
|
63
|
-
}
|
@@ -1,23 +0,0 @@
|
|
1
|
-
package org.embulk.input.dynamodb
|
2
|
-
|
3
|
-
import com.amazonaws.ClientConfiguration
|
4
|
-
import com.amazonaws.regions.Regions
|
5
|
-
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBClient
|
6
|
-
import org.embulk.config.ConfigException
|
7
|
-
|
8
|
-
object DynamoDBClient {
|
9
|
-
def create(task: PluginTask): AmazonDynamoDBClient = {
|
10
|
-
val client = new AmazonDynamoDBClient(
|
11
|
-
AwsCredentials.getCredentialsProvider(task),
|
12
|
-
new ClientConfiguration()
|
13
|
-
.withMaxConnections(50)) // SDK Default Value
|
14
|
-
|
15
|
-
if (task.getEndPoint.isPresent) {
|
16
|
-
client.withEndpoint(task.getEndPoint.get())
|
17
|
-
} else if (task.getRegion.isPresent) {
|
18
|
-
client.withRegion(Regions.fromName(task.getRegion.get()))
|
19
|
-
} else {
|
20
|
-
throw new ConfigException("At least one of EndPoint or Region must be set")
|
21
|
-
}
|
22
|
-
}
|
23
|
-
}
|
@@ -1,21 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
region: ENV_VAR
|
4
|
-
operation: scan
|
5
|
-
table: ENV_VAR
|
6
|
-
auth_method: basic
|
7
|
-
access_key: ENV_VAR
|
8
|
-
secret_key: ENV_VAR
|
9
|
-
columns:
|
10
|
-
- {name: pri-key, type: string}
|
11
|
-
- {name: sort-key, type: long}
|
12
|
-
- {name: value, type: string}
|
13
|
-
|
14
|
-
out:
|
15
|
-
type: file
|
16
|
-
path_prefix: result
|
17
|
-
file_ext: tsv
|
18
|
-
formatter:
|
19
|
-
type: csv
|
20
|
-
delimiter: "\t"
|
21
|
-
header_line: false
|
@@ -1,19 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
region: ENV_VAR
|
4
|
-
operation: scan
|
5
|
-
table: ENV_VAR
|
6
|
-
auth_method: basic
|
7
|
-
columns:
|
8
|
-
- {name: pri-key, type: string}
|
9
|
-
- {name: sort-key, type: long}
|
10
|
-
- {name: value, type: string}
|
11
|
-
|
12
|
-
out:
|
13
|
-
type: file
|
14
|
-
path_prefix: result
|
15
|
-
file_ext: tsv
|
16
|
-
formatter:
|
17
|
-
type: csv
|
18
|
-
delimiter: "\t"
|
19
|
-
header_line: false
|
@@ -1,19 +0,0 @@
|
|
1
|
-
in:
|
2
|
-
type: dynamodb
|
3
|
-
region: ENV_VAR
|
4
|
-
operation: scan
|
5
|
-
table: ENV_VAR
|
6
|
-
auth_method: env
|
7
|
-
columns:
|
8
|
-
- {name: pri-key, type: string}
|
9
|
-
- {name: sort-key, type: long}
|
10
|
-
- {name: value, type: string}
|
11
|
-
|
12
|
-
out:
|
13
|
-
type: file
|
14
|
-
path_prefix: result
|
15
|
-
file_ext: tsv
|
16
|
-
formatter:
|
17
|
-
type: csv
|
18
|
-
delimiter: "\t"
|
19
|
-
header_line: false
|