| <!DOCTYPE html> |
| <html> |
| <!--Head section for CSS/Javascript --> |
| |
| <head> |
| <meta charset="utf-8"> |
| <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'> |
| <meta name="description" content="IoT Software Update"> |
| <meta name="author" content=""> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| <title>Eclipse hawkBit - IoT Software Update</title> |
| |
| <!--Stylesheets--> |
| <!-- Bootstrap 3.3.1 --> |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> |
| <!-- Font Awesome Icons --> |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.2.0/css/font-awesome.css" rel="stylesheet" type="text/css" /> |
| <link rel="stylesheet" href="../../css/prettyPhoto.css" type="text/css" media="screen" title="prettyPhoto main stylesheet" charset="utf-8" /> |
| <!-- Custom CSS --> |
| <link href="../../css/hawkbit.css" rel="stylesheet"> |
| |
| <!--Javascript--> |
| <!-- JQuery 2.1.1--> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> |
| <!-- Bootstrap 3.3.1 JS --> |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.1/js/bootstrap.min.js" type="text/javascript"></script> |
| <script src="../../js/jquery.prettyPhoto.js" type="text/javascript" charset="utf-8"></script> |
| <script type="text/javascript" charset="utf-8"> |
| $(document).ready(function(){ |
| $("a[rel^='prettyPhoto']").prettyPhoto(); |
| }); |
| </script> |
| </head> |
| |
| <body> |
| <!--Header section Site navigation --> |
| |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| <!-- Navigation --> |
| <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation"> |
| <div class="container"> |
| <div class="navbar-header"> |
| <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse"> |
| <span class="sr-only">Toggle navigation</span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| <span class="icon-bar"></span> |
| </button> |
| <a class="navbar-brand" href="../../index.html">Eclipse hawkBitâ˘</a> |
| </div> |
| <div class="collapse navbar-collapse wow fadeIn" id="navbar-collapse" data-wow-delay="0.2s"> |
| <ul class="nav navbar-nav pull-right"> |
| |
| <li > |
| |
| <a href="../../news/index.html">News</a> |
| |
| |
| </li> |
| |
| <li > |
| |
| <a href="../../documentation/overview/introduction.html">Documentation</a> |
| |
| |
| </li> |
| |
| </ul> |
| </div> |
| <!-- /.navbar-collapse --> |
| </div> |
| <style>#forkongithub a{background:#8d0c0c;color:#fff;text-decoration:none;font-family:Arial, Helvetica, sans-serif;text-align:center;font-weight:bold;padding:5px 40px;font-size:12px;line-height:3rem;position:relative;transition:0.5s;}#forkongithub a:hover{background:#c11;color:#fff;}#forkongithub a::before,#forkongithub a::after{content:"";width:100%;display:block;position:absolute;top:1px;left:0;height:1px;background:#fff;}#forkongithub a::after{bottom:1px;top:auto;}@media screen and (min-width:800px){#forkongithub{position:fixed;display:block;top:0;right:0;width:50px;overflow:visible;height:200px;z-index:9999;}#forkongithub a{width:260px;position:absolute;top:40px;right:-60px;transform:rotate(45deg);-webkit-transform:rotate(45deg);-ms-transform:rotate(45deg);-moz-transform:rotate(45deg);-o-transform:rotate(45deg);}}</style><span id="forkongithub"><a href="https://github.com/eclipse/hawkbit">Fork me on GitHub</a></span> |
| <!-- /.container --> |
| </nav> |
| |
| <div id="header_wrapper" class="container"> |
| <div class="nav-bar col-md-3"> |
| <nav class="navmenu navmenu-default" role="navigation"> |
| <ul class="nav navmenu-nav"> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li> |
| Introduction |
| <ul class="nav navmenu-nav"> |
| <!-- 2nd level --> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/overview/introduction.html">Overview</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/overview/features.html">Features</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/overview/getting-started.html">Getting Started</a> |
| |
| |
| </li> |
| |
| |
| |
| </ul> |
| </li> |
| |
| |
| |
| <li> |
| Concepts |
| <ul class="nav navmenu-nav"> |
| <!-- 2nd level --> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/architecture/architecture.html">Architecture</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/architecture/datamodel.html">Data model</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/architecture/targetstate.html">Target States</a> |
| |
| |
| </li> |
| |
| |
| |
| </ul> |
| </li> |
| |
| |
| |
| <li> |
| Interfaces |
| <ul class="nav navmenu-nav"> |
| <!-- 2nd level --> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/interfaces/interfaces.html">Overview</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/interfaces/management-ui.html">Management UI</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/interfaces/management-api.html">Management API</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/interfaces/ddi-api.html">DDI API</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/interfaces/dmf-api.html">DMF API</a> |
| |
| |
| </li> |
| |
| |
| |
| </ul> |
| </li> |
| |
| |
| |
| <li> |
| Security |
| <ul class="nav navmenu-nav"> |
| <!-- 2nd level --> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/security/security.html">Overview</a> |
| |
| |
| </li> |
| |
| |
| |
| </ul> |
| </li> |
| |
| |
| |
| <li> |
| Guides |
| <ul class="nav navmenu-nav"> |
| <!-- 2nd level --> |
| <!--base to have relative path for offline navigation --> |
| |
| |
| |
| |
| |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/guide/runhawkbit.html">Build and Run hawkBit</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/guide/clustering.html">Clustering</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/guide/customtheme.html">Theme Customization</a> |
| |
| |
| </li> |
| |
| |
| |
| <li > |
| |
| <a href="../../documentation/guide/feignclient.html">Create Feign Client</a> |
| |
| |
| </li> |
| |
| |
| |
| </ul> |
| </li> |
| |
| |
| |
| </ul> |
| </nav> |
| </div> |
| |
| |
| <div id="page" class="col-md-9"> |
| <div class="inner"> |
| <div id="maincontainer"> |
| <section id="top" class="documentation-section"> |
| <div class="row"> |
| <div class="span8 offset3"> |
| <!--base to have relative path for offline navigation --> |
| |
| <h1 id="create-feign-rest-client">Create Feign REST Client</h1> |
| <p>In this guide we describe how to create a <a href="https://github.com/Netflix/feign">Feign</a> Rest Client based on a <a href="http://projects.spring.io/spring-boot/">Spring Boot</a> Application. <a href="https://projects.eclipse.org/projects/iot.hawkbit">hawkBit</a> provides REST interfaces for <a href="https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-api">Management API</a> and [DDI API] (https://github.com/eclipse/hawkbit/tree/master/hawkbit-ddi-api). Using this interfaces you can create a feign client with the help of the [feign inheritance support] (http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance). |
| Our <a href="https://github.com/eclipse/hawkbit/tree/master/examples">example</a> modules demonstrate how to create <a href="https://github.com/Netflix/feign">Feign</a> client resources. Here you can find the <a href="https://github.com/eclipse/hawkbit/tree/master/examples/hawkbit-example-mgmt-feign-client">Management API client resources</a> and the <a href="https://github.com/eclipse/hawkbit/tree/master/examples/hawkbit-example-ddi-feign-client">DDI client resources</a>. |
| A small <a href="https://github.com/eclipse/hawkbit/blob/master/examples/hawkbit-example-mgmt-simulator/src/main/java/org/eclipse/hawkbit/mgmt/client/Application.java">simulator application</a> demonstrates how you can interact with the <a href="https://projects.eclipse.org/projects/iot.hawkbit">hawkBit</a> via the <a href="https://github.com/eclipse/hawkbit/wiki/Management-API">Management API |
| </a>. </p> |
| |
| <p>Note: A hawkbit application have to be run. Therefore, you can use our <a href="https://github.com/eclipse/hawkbit/tree/master/examples/hawkbit-example-app">example application</a></p> |
| |
| <h3 id="example-managment-api-simulator">Example Managment API simulator</h3> |
| |
| <p>In the follow code section, you can a see a feign client resource example. The interface extend the orgin api inteface to declare the <code>@FeignClient</code>. The <code>@FeignClient</code>declares that a REST client with that interface should be created. </p> |
| |
| <pre><code>@FeignClient(url = "${hawkbit.url:localhost:8080}/" + MgmtRestConstants.TARGET_V1_REQUEST_MAPPING) |
| public interface MgmtTargetClientResource extends MgmtTargetRestApi { |
| } |
| </code></pre> |
| |
| <p>This interface can be autowired and use as a normal java interface:</p> |
| |
| <pre><code>public class CreateStartedRolloutExample { |
| |
| @Autowired |
| private MgmtTargetClientResource targetResource; |
| |
| |
| public void run() { |
| // create ten targets |
| targetResource.createTargets(new TargetBuilder().controllerId("00-FF-AA-0").name("00-FF-AA-0") |
| .description("Targets used for rollout example").buildAsList(10)); |
| } |
| |
| </code></pre> |
| |
| <p>At <a href="https://github.com/eclipse/hawkbit/tree/master/examples/hawkbit-example-core-feign-client">hawkbit-example-core-feign-client</a> is a spring configuration to auto configure some beans, which can be reused for a own feign client.</p> |
| |
| <pre><code>@Configuration |
| @ConditionalOnClass(Feign.class) |
| @Import(FeignClientsConfiguration.class) |
| public class FeignClientConfiguration { |
| |
| @Bean |
| public ApplicationJsonRequestHeaderInterceptor jsonHeaderInterceptor() { |
| return new ApplicationJsonRequestHeaderInterceptor(); |
| } |
| |
| @Bean |
| public Contract feignContract() { |
| return new IgnoreMultipleConsumersProducersSpringMvcContract(); |
| } |
| } |
| |
| </code></pre> |
| |
| </div> |
| </div> |
| </section> |
| </div> |
| </div> |
| </div> |
| </div> |
| <!-- Footer --> |
| <footer> |
| <div class="container"> |
| <div class="row"> |
| <div class="col-md-4"> |
| <h3 class="footer-links-header">Quick Links</h3> |
| <ul class="footer-links clearfix"> |
| <li><a href="http://www.eclipse.org/legal/privacy.php">Privacy Policy</a></li> |
| <li><a href="http://www.eclipse.org/legal/termsofuse.php">Terms of Use</a></li> |
| <li><a href="http://www.eclipse.org/legal/copyright.php">Copyright Agent</a></li> |
| <li><a href="http://www.eclipse.org/legal/">Legal</a></li> |
| </ul> |
| <ul class="footer-links clearfix"> |
| <li><a href="http://www.eclipse.org">Eclipse Home</a></li> |
| <li><a href="http://marketplace.eclipse.org/">Market Place</a></li> |
| <li><a href="http://live.eclipse.org/">Eclipse Live</a></li> |
| <li><a href="http://www.planeteclipse.org/">Eclipse Planet</a></li> |
| </ul> |
| </div> |
| <div class="col-md-2"> |
| |
| </div> |
| </footer> |
| |
| <!--/.Footer--> |
| |
| </body> |
| |
| </html> |