GithubHelp home page GithubHelp logo

knoppiks / hap-java-client Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 232 KB

A Java library which implements a generic Hypermedia Application Protocol (HAP) client.

License: Apache License 2.0

Java 100.00%

hap-java-client's Introduction

This software is ALPHA.

HAP Java Client

A Java library which implements a generic Hypermedia Application Protocol (HAP) client.

Installation

When using maven you can simply add the following dependency to your pom.xml.

<dependency>
    <groupId>de.knoppiks</groupId>
    <artifactId>hap-java-client</artifactId>
    <version>0.1</version>
</dependency>

Usage

Examples for all Methods the HapClient offers can be found in the ClientTodoIT in the src/test/ directory.

Fetch a Representation

import de.knoppiks.hap.client.Hap;
import de.knoppiks.hap.client.HapClient;
import de.knoppiks.hap.client.HapEntity;
import org.apache.http.impl.client.HttpClients;
import static com.cognitect.transit.TransitFactory.Format.JSON;

HapClient client = Hap.createClient(HttpClients.createDefault(), JSON);
HapEntity entity = client.fetch(URI.create("..."));

### Execute a Query

```java
import de.knoppiks.hap.client.Hap;
import de.knoppiks.hap.client.HapClient;
import de.knoppiks.hap.client.HapEntity;
import de.knoppiks.hap.client.RequestBuilders;
import de.knoppiks.hap.client.model.Query;
import org.apache.http.impl.client.HttpClients;
import static com.cognitect.transit.TransitFactory.Format.JSON;

HapClient client = Hap.createClient(HttpClients.createDefault(), JSON);
HapEntity entity = client.fetch(URI.create("..."));
Query query = entity.getQuery(keyword("...")).get();
HapEntity result = client.execute(RequestBuilders.query(query).put(keyword("..."), ...));

Create a new Resource

Use RequestBuilders to build a create request from an existing form. You can specify your create request parameters by calling put(...) on the RequestBuilder. Note: Currently parameters are not checked against the parameters allowed in the form at all. You may inspect which parameters may be used by calling getParams() on the form. Type checking via Schemas may be added later.

import de.knoppiks.hap.client.Hap;
import de.knoppiks.hap.client.HapClient;
import de.knoppiks.hap.client.HapEntity;
import de.knoppiks.hap.client.RequestBuilders;
import de.knoppiks.hap.client.model.Form;
import org.apache.http.impl.client.HttpClients;
import static com.cognitect.transit.TransitFactory.Format.JSON;

HapClient client = Hap.createClient(HttpClients.createDefault(), JSON);
HapEntity entity = client.fetch(URI.create("..."));
Form form = entity.getForm(keyword("...")).get();
URI location = client.create(RequestBuilders.create(form).put(keyword("..."), "..."));

Delete a Resource

import de.knoppiks.hap.client.Hap;
import de.knoppiks.hap.client.HapClient;
import org.apache.http.impl.client.HttpClients;
import static com.cognitect.transit.TransitFactory.Format.JSON;

HapClient client = Hap.createClient(HttpClients.createDefault(), JSON);
client.delete(URI.create("..."));

Update a Resource

import de.knoppiks.hap.client.Hap;
import de.knoppiks.hap.client.HapClient;
import de.knoppiks.hap.client.HapEntity;
import org.apache.http.impl.client.HttpClients;
import static com.cognitect.transit.TransitFactory.Format.JSON;

HapClient client = Hap.createClient(HttpClients.createDefault(), JSON);
HapEntity state = client.fetch(URI.create("..."));
HapEntity newState = client.update(state.updateData(...));

Schema Support

There is currently no schema support.

License

Copyright © 2015 Jonas Wagner

Hap Java Client is licensed under the open-source Apache 2.0 license.

hap-java-client's People

Contributors

alexanderkiel avatar knoppiks avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.