A REST client for Kii Cloud for Android and Java applications.
This library is beta release.
API incompatibility changes will occur in beta releases.
Download the latest JAR or grab via Maven:
<dependency>
<groupId>com.kii.cloud.rest.client</groupId>
<artifactId>kii-rest-client4j</artifactId>
<version>0.5.8</version>
</dependency>
or Gradle:
compile 'com.kii.cloud.rest.client:kii-rest-client4j:0.5.8'
kii-rest-client4j is published in JCenter repository. so you need to add a repository to your project.
Maven:
<repositories>
<repository>
<id>jcenter</id>
<url>http://jcenter.bintray.com</url>
</repository>
</repositories>
Gradle:
repositories {
jcenter()
}
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.3.1</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp-urlconnection</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp</groupId>
<artifactId>okhttp-ws</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okio</groupId>
<artifactId>okio</artifactId>
<version>1.4.0</version>
</dependency>
</dependencies>
- Managing Users
- Sing-Up
- Sign-In
- Authenticating with the SocialNetworkConnector (only Generating URL)
- Authenticating with the Native Applications
- Refreshing Token
- Changing Passwords
- Resetting Passwords
- Phone/Email Verification
- Retrieving/Updating/Deleting Users
- Pseudo Users
- Managing Things
- Registering/Unregistering Thing
- Retrieving/Updating Thing
- Enable/Disable Thing
- Checking if a Thing is Registered
- Geting an Access Token
- Adding Owners with Simple Flow
- Adding Owners with PIN Code Validation Flow
- Checking the Ownership
- Getting a list of Owners
- Removing the Ownership
- Managing Groups
- Creating/Updating/Deleting Groups
- Changing a Group Owner
- Listing Group
- Listing Group Members
- Adding/Removing Group Members
- Managing Data
- Granting/Revoking an Permission to a Bucket
- Creating/Retrieving/Updating/Deleting Objects
- Querying for Objects
- Uploading Object Bodies
- Downloading Object Bodies
- Moving Object Bodies
- Publishing Object Bodies
- Deleting Object Bodies
- Creating/Deleting Buckets
- Granting/Revoking an Permission to a Objects
- Granting/Revoking an Permission to a Scope
- Managing Analytics
- Uploading Event Data
- Fetching Analytics Results (Tabular/Grouped)
- Creating/Listing/Retrieving/Deleting ConversionRules
- Creating/Listing/Retrieving/Deleting AggregationRules
- Managing Push Notification
- Creating/Deleting Topic
- Listing Topic names
- Subscribe/Unsubscribe Topic
- Checking Subscription status
- Sending Message
- Install/Uninstall PushInstallation
- Retrieving/Listing PushInstallation
- Admin Features
- Getting app admin token
- Getting/Setting App Configuration Parameters
- Getting/Setting ThingType Configuration
- Securing Data
- Setting ACL to Scope
- Setting ACL to Buckets
- Setting ACL to Topics
- Setting ACL to Objects
- Server Extension
- Deploying Server Code
- Executing Server Code
- Listing the Available Versions
- Switch the Active Server Code
- Getting Server Source Code
- Deleting Server Code
- Deploying Server Hook Config File
- Getting Server Hook Config File
- Deleting Server Hook Config File
- Querying for Execution Result
- Getting Execution Result
- Getting Devlog
- Tailing Devlog
API design is very simple. There are two kinds of classes.
The first is resource classes that represents the REST API.
The second is model classes that represents the REST request and response.
- edit the
src/test/resources/test_config.json
if you want to execute all unit tests. - build project using maven.
target/kii-rest-client4j.jar
will be created when build is successful.
mvn package
If you want to skip unit tests, try following command.
mvn package -DskipTests
If you want to calculate code coverage, try following command.
mvn cobertura:cobertura
open target/site/cobertura/index.html
Unit tests sends request to KiiCloud server according src/test/resources/test_config.json
settings.
Some test cases need app admin credentials or access token that is issued by SNS, but you must not push the these credentials to the github.
You can write these credentials to src/test/resources/test_admin_credential_config.json
instead of test_config.json
.
test_admin_credential_config.json
is specified by the .gitignore file.
If you don't specify these credentials, some tests will be skipped(ignored).
For more detail, Please refer to the TestEnvironments.java.
// initialize rest client
KiiRest rest = new KiiRest("APP_ID", "APP_KEY", KiiRest.Site.US);
// register a user
KiiNormalUser user = new KiiNormalUser()
.setEmail("test@example.com")
.setCountry("US");
user = rest.api().users().register(user, "pasword");
rest.setCredentials(user);
// create app scope object
KiiObject appObject = new KiiObject()
.set("user_id", user.getUserID())
.set("email", user.getEmail());
rest.api().buckets("app_bucket").objects().save(appObject);
// create user scope object
KiiObject userObject = new KiiObject()
.set("age", 30);
rest.api().users(user).buckets("user_bucket").objects().save(userObject);
//update object
appObject.set("email", "TEST@example.com");
rest.api().buckets("app_bucket").objects(appObject).update(appObject);
For more examples, please refer to the test code.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.