Java SDK for Sirv REST API

The Sirv REST API let's you perform more than 40 actions on your Sirv account, such as upload, search, delete, move, copy, fetch remote URL etc. REST API Documentation: https://apidocs.sirv.com/#getting-started

License

License

Categories

Categories

Java Languages
GroupId

GroupId

com.sirv
ArtifactId

ArtifactId

sirv-java-sdk
Last Version

Last Version

1.0
Release Date

Release Date

Type

Type

pom
Description

Description

Java SDK for Sirv REST API
The Sirv REST API let's you perform more than 40 actions on your Sirv account, such as upload, search, delete, move, copy, fetch remote URL etc. REST API Documentation: https://apidocs.sirv.com/#getting-started
Project URL

Project URL

https://sirv.com
Source Code Management

Source Code Management

https://github.com/sirv/sirv-rest-api-java

Download sirv-java-sdk

Filename Size
sirv-java-sdk-1.0.pom 5 KB
Browse

How to add to project

<!-- https://jarcasting.com/artifacts/com.sirv/sirv-java-sdk/ -->
<dependency>
    <groupId>com.sirv</groupId>
    <artifactId>sirv-java-sdk</artifactId>
    <version>1.0</version>
    <type>pom</type>
</dependency>
// https://jarcasting.com/artifacts/com.sirv/sirv-java-sdk/
implementation 'com.sirv:sirv-java-sdk:1.0'
// https://jarcasting.com/artifacts/com.sirv/sirv-java-sdk/
implementation ("com.sirv:sirv-java-sdk:1.0")
'com.sirv:sirv-java-sdk:pom:1.0'
<dependency org="com.sirv" name="sirv-java-sdk" rev="1.0">
  <artifact name="sirv-java-sdk" type="pom" />
</dependency>
@Grapes(
@Grab(group='com.sirv', module='sirv-java-sdk', version='1.0')
)
libraryDependencies += "com.sirv" % "sirv-java-sdk" % "1.0"
[com.sirv/sirv-java-sdk "1.0"]

Dependencies

compile (2)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.12.0
org.projectlombok : lombok jar 1.18.16

Project Modules

  • sirvjavasdkspring
  • sirvjavasdkcore

Sirv REST API SDK for Java

The Sirv REST API let's you perform more than 40 actions on your Sirv account, such as upload, search, delete, move, copy, fetch remote URL etc.

REST API Documentation: https://apidocs.sirv.com/#getting-started

Get started

To use this Java SDK, specify it as a project dependency in Maven:

<dependencies>
  <dependency>
    <groupId>sirv.com</groupId>
    <artifactId>sirv-java-sdk-spring</artifactId>
    <version>1.0-SNAPSHOT</version>
  </dependency>
</dependencies>

Spring MVC usage example

This SDK can be used in Spring MVC projects.

Example of SDK usage:

import com.sirv.RestClient;
import com.sirv.SirvClient;
import com.sirv.SirvClientImpl;
import com.sirv.account.AccountClient;
import com.sirv.account.model.AccountInformation;
import com.sirv.spring.RestTemplateAdapter;

public class Test {
    public static void main(String[] args) {
        // setup credentials
        String clientId = "yourClientId";
        String clientSecret = "yourClientSecret";
 
        //setup sirv client
        RestClient restClient = new RestTemplateAdapter();
        SirvClient sirvClient = new SirvClientImpl(clientId, clientSecret, restClient);
 
        // get accountClient
        AccountClient accountClient = sirvClient.getAccountClient();
        // get account information
        AccountInformation information = accountClient.getInformation();
        System.out.println(information);
    }
}

Replace yourClientSecret and yourClientSecret with the client ID and secret from your Sirv account: https://my.sirv.com/#/account/settings/api

Token

If the bearer authentication token has expired (after 20 minutes), the system will automatically request a new one.

sirvClient.getToken() - get new token sirvClient.isAlive() - check if token is alive

Errors

If the API returns an error, the SDK returns an exception with details about the error SirvException class.

Folder structure

In this projects' folder structure, sirvjavasdkcorecontains contains the abstract SDK code, without integration with a specific REST client.

  • account – Sirv account API
  • exception – SDK exception
  • files - Sirv files API
  • json – JSON config
  • model – authorization of API models
  • statistic - Sirv statistic API
  • user - Sirv user API
  • RestClient.java – interface of REST client
  • SirvClient.java – interface of Sirv client
  • SirvClientImpl.java – implementation of Sirv client

The folder sirvjavasdkspring contains the implementation of RestClient.java, based upon the Spring RestTemplate.

com.sirv

Sirv

Sirv is a dynamic image processing for static, zoom and 360 degree images. Automatic image optimization, responsize sizing & lazy loading, delivered by CDN.

Versions

Version
1.0