Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
alfespa17 committed May 4, 2021
1 parent 775bc05 commit 60b2580
Show file tree
Hide file tree
Showing 67 changed files with 1,132 additions and 21 deletions.
48 changes: 30 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,23 +1,35 @@
# Compiled class file
*.class
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

# Log file
*.log
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

# BlueJ files
*.ctxt
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

# Mobile Tools for Java (J2ME)
.mtj.tmp/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar
### VS Code ###
.vscode/

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
.mvn/
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright [yyyy] [name of copyright owner]
Copyright 2021 Alfredo España

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
19 changes: 17 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,17 @@
# azb-api-client-spring-boot-starter
Spring boot starter client to consume azb-api
# Spring Boot Starter to consume azb-api

## Introduction

This repository is for Spring Boot Starters of azb-api.

## Client library

Simply add the following dependency to your project's `pom.xml` will enable you to use the `RestClient` class.

```xml
<dependency>
<groupId>org.azbuilder.api.spring.starter</groupId>
<artifactId>api-client-spring-boot-starter</artifactId>
<version>0.0.1</version>
</dependency>
```
35 changes: 35 additions & 0 deletions api-client-spring-boot-autoconfigure/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/

.mvn/
71 changes: 71 additions & 0 deletions api-client-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.azbuilder.api.spring.autoconfigure</groupId>
<artifactId>api-client-spring-boot-autoconfigure</artifactId>
<version>${revision}</version>
<name>api-client-spring-boot-autoconfigure</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<spring-cloud.version>2020.0.2</spring-cloud.version>
<gson.version>2.8.6</gson.version>
<feign.version>11.1</feign.version>
<okhttp.version>4.9.1</okhttp.version>
<revision>0.0.1</revision>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>

<distributionManagement>
<repository>
<id>github</id>
<name>GitHub Packages</name>
<url>https://maven.pkg.github.com/AzBuilder/azb-api-client-spring-boot-starter</url>
</repository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.azbuilder.api.client</groupId>
<artifactId>api-client</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-gson</artifactId>
<version>${feign.version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-slf4j</artifactId>
<version>${feign.version}</version>
</dependency>
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-okhttp</artifactId>
<version>${feign.version}</version>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.azbuilder.api.spring.autoconfigure;

import feign.Feign;
import feign.okhttp.OkHttpClient;
import org.azbuilder.api.client.RestClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import feign.slf4j.Slf4jLogger;
import feign.Logger;
import feign.gson.GsonDecoder;
import feign.gson.GsonEncoder;

@Configuration
@EnableConfigurationProperties(RestClientProperties.class)
@ConditionalOnMissingBean(RestClient.class)
public class RestClientAutoConfiguration {

@Autowired
private RestClientProperties restClientProperties;

@Bean
public RestClient terraformClient(RestClientProperties restClientProperties) {
RestClient restClient = Feign.builder()
.encoder(new GsonEncoder())
.decoder(new GsonDecoder())
.client( new OkHttpClient())
//.logger(new Slf4jLogger())
//.logLevel(Logger.Level.BASIC)

.target(RestClient.class, restClientProperties.getUrl());
return restClient;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package org.azbuilder.api.spring.autoconfigure;

import lombok.Getter;
import lombok.Setter;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.annotation.PropertySources;
import org.springframework.stereotype.Component;

@Component
@Getter
@Setter
@PropertySources({
@PropertySource(value = "classpath:application.properties", ignoreResourceNotFound = true),
@PropertySource(value = "classpath:application-${spring.profiles.active}.properties", ignoreResourceNotFound = true)
})
@ConfigurationProperties(prefix = "org.azbuilder.api")
public class RestClientProperties {
private String url;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
org.azbuilder.api.spring.autoconfigure.RestClientAutoConfiguration
33 changes: 33 additions & 0 deletions api-client-spring-boot-starter-sample/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/

### VS Code ###
.vscode/
47 changes: 47 additions & 0 deletions api-client-spring-boot-starter-sample/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.4.3</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.azbuilder.api.client.sample</groupId>
<artifactId>api-client-starter-sample</artifactId>
<version>${revision}</version>
<name>api-client-starter-sample</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
<revision>0.0.1</revision>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.azbuilder.api.spring.starter</groupId>
<artifactId>api-client-spring-boot-starter</artifactId>
<version>${revision}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.azbuilder.api.client.sample;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ApiClientStarterSampleApplication {

public static void main(String[] args) {
SpringApplication.run(ApiClientStarterSampleApplication.class, args);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.azbuilder.api.client.sample;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import static org.junit.jupiter.api.Assertions.assertNotNull;

import org.azbuilder.api.client.RestClient;

@SpringBootTest
class ApiClientStarterSampleApplicationTests {

@Autowired
RestClient restClient;

@Test
void contextLoads() {
assertNotNull(restClient);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.azbuilder.api.url=http://localhost:8080
Loading

0 comments on commit 60b2580

Please sign in to comment.