Skip to content

orandev/lithium

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Wire™

Wire logo

Lithium

Build Status

  • Lithium is Wire Services SDK written in Java

How to use it to build your bots?

  • In your pom.xml:
<repositories>
    <repository>
        <id>lithium</id>
        <url>https://packagecloud.io/dkovacevic/lithium/maven2</url>
        <releases>
            <enabled>true</enabled>
        </releases>
    </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>com.wire</groupId>
        <artifactId>lithium</artifactId>
        <version>3.0.3</version>
    </dependency>
<dependencies>

If you want to use Version resource (API endpoint), you must create version file during the build. For example, during the Docker build, one can put following code inside Dockerfile:

# create version file
ARG release_version=development
ENV RELEASE_FILE_PATH=/path/to/release.txt
RUN echo $release_version > $RELEASE_FILE_PATH

And than add build argument ie. in the build pipeline like that.

Tutorial:

Bot API Documentation

How to build the project

Requirements:

To build the library, run:

mvn install

How to register your service with Wire

The manage.sh script helps you register as a service provider, create a certificate, and register your service instance.

Script requirements

How to use the script

In order to register a service, you need to generate a certificate (or bring your own), register as a provider and then register the service.

Using the manage.sh script:

  • Register as a provider with manage.sh new-provider. If everything goes well, the response will contain a password and provider ID, and you should get an email. Open the email and follow the link in the email to confirm your identity. You need to do this only once, even when developing multiple services. This will save the credentials in the local folder, for further authentication.
  • If you don't have a certificate already, create a new certificate with manage.sh new-cert and follow the instructions. This needs to match the certificate that is used for the SSL termination on your service.
  • Deploy your service and make it accessible by public IP, using HTTPS and the certificate you created at step one.
  • Obtain an authentication token with manage.sh auth-provider. This is a temporary token to perform authenticated requests, and will need to be refreshed periodically if you don't use the script for more than 10 minutes.
  • Register a new service with manage.sh new-service and enter the required information. Make sure the base URL is an https URL. You will receive an service auth token.
  • Once a server is created, you can update it with manage.sh update-service.
  • Edit the YAML configuration file of your service and add the service token you received at the previous step.
  • (Re)-start the service with the new configuration file.
  • Activate the service with manage.sh update-service-conn to make it enabled

Use Hello World sample service as your first service

Environment variables used:

  • WIRE_API_HOST: Wire Backend. https://prod-nginz-https.wire.com by default
  • SERVICE_TOKEN: Your service authentication token. All requests sent by the BE will have this token as Bearer Authorization HTTP header

Logging to JSON

Wire uses JSON logging in the production. To enable JSON logging one must specify json-console appender in the Dropwizard yaml.

logging:
  appenders:
    - type: json-console

Other examples of Wire Services

Other implementations of Bot API

About

Wire Services JDK

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 90.8%
  • Shell 9.2%