Skip to content

Commit

Permalink
Switching credentials to use user credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Yates committed Apr 10, 2017
1 parent ad37e7b commit 4e245fd
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
20 changes: 20 additions & 0 deletions java/example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,42 @@
<name>Fineo Client - Example</name>
<description>A simple example project for interacting with the Fineo API</description>

<repositories>
<repository>
<id>maven.fineo</id>
<url>http://maven.fineo.io/release</url>
</repository>
</repositories>

<properties>
<fineo.version>1.1.4-SNAPSHOT</fineo.version>
</properties>

<dependencies>
<dependency>
<groupId>io.fineo.client</groupId>
<artifactId>common</artifactId>
<version>${fineo.version}</version>
</dependency>
<dependency>
<groupId>io.fineo.client</groupId>
<artifactId>cognito-auth</artifactId>
<version>${fineo.version}</version>
</dependency>
<dependency>
<groupId>io.fineo.client</groupId>
<artifactId>jdbc</artifactId>
<version>${fineo.version}</version>
</dependency>
<dependency>
<groupId>io.fineo.client.models</groupId>
<artifactId>schema</artifactId>
<version>${fineo.version}</version>
</dependency>
<dependency>
<groupId>io.fineo.client.models</groupId>
<artifactId>write</artifactId>
<version>${fineo.version}</version>
</dependency>
<dependency>
<groupId>commons-dbutils</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
import com.fasterxml.jackson.annotation.JsonProperty;

/**
*
* A simple example event to send. All events need:
* <ul>
* <li>metrictype</li>
* <li>timestamp</li>
* </ul>
* Or a way to identify those fields through a metric key name or field alias.
*/
public class Event {
private final String metrictype = ExampleDriver.METRIC_NAME;
Expand All @@ -14,6 +19,7 @@ public class Event {
public Event(String f1, int f2) {
this.f1 = f1;
this.f2 = f2;
// every event needs a timestamp
this.timestamp = System.currentTimeMillis();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.fineo.client.FineoClientBuilder;
import io.fineo.client.auth.CredentialsHelper;
import io.fineo.client.model.schema.SchemaApi;
import io.fineo.client.model.schema.field.CreateFieldRequest;
import io.fineo.client.model.schema.metric.CreateMetricRequest;
Expand All @@ -28,8 +29,12 @@
/**
* A simple example for creating a simple schema, uploading data and then reading that data back.
* <p>
* API KEY is the first argument. Access credentials are loaded using the default AWS chain
* {@link DefaultAWSCredentialsProviderChain}.
* Arguments (in order):
* <ol>
* <li>API Key</li>
* <li>Email (JDBC username)</li>
* <li>Password (JDBC password)</li>
* </ol>
* <p>
* After running this driver you should be able to see the 'example metric' schema in the
* <a href="http://app.fineo.io>UI</a> and be able to read two rows from the 'example metric' table.
Expand All @@ -44,7 +49,8 @@ public static void main(String[] args) throws Exception {
String apikey = args[0];
FineoClientBuilder builder = new FineoClientBuilder()
.withApiKey(apikey)
.withCredentials(new DefaultAWSCredentialsProviderChain());
// you can also provide static credentials if you want to send as a 'device'
.withCredentials(CredentialsHelper.getUserHelper(args[1], args[2]));
setupSchema(builder);
write(builder);
read(apikey, args[1], args[2]);
Expand Down
14 changes: 4 additions & 10 deletions java/example/src/main/resources/logback.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,11 @@
</appender>


<logger name="io.fineo" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>

<logger name="fineo.client" level="DEBUG" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="io.fineo" level="DEBUG"/>
<logger name="fineo.client" level="DEBUG"/>
<!-- this logs like crazy at DEBUG -->
<logger name="fineo.client.org.asynchttpclient" level="INFO" additivity="false">
<appender-ref ref="CONSOLE"/>
</logger>
<logger name="fineo.client.org.asynchttpclient" level="INFO"/>
<logger name="io.fineo.client.auth" level="INFO"/>

<root level="WARN">
<appender-ref ref="CONSOLE"/>
Expand Down

0 comments on commit 4e245fd

Please sign in to comment.