Guidewire REST API Client

The InsuranceSuite REST API Client provides functionality to make outbound HTTP calls to internal or third-party REST services.

Overview

REST API Client

Available since

Guidewire Banff

Easily connect Guidewire to other services.

The InsuranceSuite REST API Client provides functionality that Guidewire applications and integrations use to make outbound HTTP calls to third-party OpenAPI Spec-compliant REST services. Using the client enables loosely-coupled external code to be invoked by events that are sourced in InsuranceSuite and other Guidewire applications.

Version compatibility:

  • Guidewire Cloud: Banff release of InsuranceSuite or greater
  • Self-managed: InsuranceSuite 10.1 or greater

The Guidewire REST API client consists of two modules, a client library and a client plugin:

  • The client library provides fault tolerance features that integration developers use to make synchronous REST API calls from InsuranceSuite to internal or external services
  • The client plugin generates REST API for making outbound HTTP requests to internal or external OpenAPI Spec-compliant REST services
Rest API Client Architecture

Architecture of the Guidewire REST API Client (click to expand).

Related Info

API
Easily connect applications with Guidewire using RESTful APIs. Or build completely headless experiences for Guidewire.
Use Case
Integration developers are the life blood of innovation. Start your journey here to learn how to connect anything to Guidewire.
Get updates for Guidewire developers delivered right to your inbox.

About

Client Library

Provides fault tolerance features that integration developers use to make synchronous REST API calls from InsuranceSuite to internal or external services.

The client library is distributed as a JAR file. The library works with OpenFeign annotated API and Jackson annotated data objects. Integration developers can manually create these objects or provide existing. If their REST service complies with the OpenAPI Spec they can use the client plugin to generate that set of classes.

The library provides the following features:

  • Code generation in Java and isolation from Gosu for rapid development
  • Integrates with Resilience4j to provide lightweight, easy-to-use fault tolerance library. Reseliense4j introduces higher-order functions (decorators) to enhance any functional interface, lambda expression, or method reference with a Circuit Breaker, and Retry. You can stack more than one decorator on any functional interface, lambda expression or method reference
  • Integrates with OpenFeign to facilitate the creation of web service client implementations, with quality of service features, configurable and customizable clients. Uses OpenFeign to implement timeout
  • Fault tolerance with retrycircuit breaker, and fallback
  • Observability with logging and traceability
  • Authentication that supports Basic, API Key, Bearer, OAuth 2.0, and Mutual TLS authentications
  • Uses Apache HttpClient for robust client connections
  • Uses Apache OAuth implementation for OAuth authentication
  • By default uses InsuranceSuite standard headers in logging context
  • Uses Jackson as JSON parser

 

About

Client Plugin

Generates REST API for making outbound HTTP requests to internal or external OpenAPI Spec-compliant REST services.

You use the client plugin to generate an OpenFeign based REST client against a service that supports the OpenAPI Spec. If you have an existing OpenFeign based REST API interface you can use the REST API library without the client generation and take advantage of the fault tolerance features.

The client plugin provides the following features:

  • Uses OpenAPI Generator to generate API client libraries, server stubs, documentation and configuration automatically against an OpenAPI Spec-compliant REST API service endpoint.

Setup

Before You Begin

A few items to explore before you get started.

Using the REST API client Plugin requires basic familiarity with Gradle. Guidewire recommends using InteliJ as Interactive Development Environment (IDE). To start using the REST API client, install the following software:

Software
URL
Description
Gradle https://github.com/gradle/gradle Build automation framework
IntelliJ https://www.jetbrains.com/idea/ Interactive Development Environment (IDE)

The REST API client is implemented using the following Open Source libraries. Use the provided links to explore their features:

Library
URL
Description
OpenFeign https://github.com/OpenFeign/feign OpenFeign is a microservice invocation framework, which is mainly used in the consumer side, that is, invoking services.
Resilience4J https://resilience4j.readme.io/docs Fault tolerance library
Jackson https://github.com/FasterXML/jackson JSON library

 

Making Connections

Getting Started with the REST API Client

Download the client and get started integrating Guidewire to other services.

The REST API client project is configured to use the PetStore REST service to illustrate how to generate the REST API client with this service. Initially, you use this configuration to test the generated client in your InsuranceSuite application. Next, you modify the project settings to configure the OpenAPI-compliant service endpoints and generate your own client. To start using the code generation plugin you need to unzip the distribution zip file and open the Gradle project in your IDE. The instructions in this guide assume that you use IntelliJ.

Step 1: Get the REST API Client

For Dobson and later releases, the REST API Client code is available in your code repository. As of our Elysian release, it is located in the modules/restapiclient directory.

Self-managed customers and partners can download the REST API Client code by logging into Guidewire Community or our Partner portal, respectively:

Customers:

Partners:

Step 2: Unzip the Project to Your Environment

  1. Unzip the file to your local file system
  2. Import the Gradle project to IntelliJ, or the IDE that you use

Step 3: Update the Project Configuration

Update the following configuration files to configure your client:

  1. Open the build.gradle file to update the following three parameters:
    • gwRestGen_endpoint_package Defines the generated client package name
    • gwRestGen_endpoint_source Defines the source for the endpoint. It can be a REST service endpoint OpenAPI spec URL or a local file path to the OpenAPI spec JSON file.
    • gwRestGen_isInsuranceSuite Defines the client deployment target. When the target is an InsuranceSuite application the build task packages the client along with the necessary libraries.

ext {
  gwRestGen_endpoint_package = "petstore"
  gwRestGen_endpoint_source = "https://petstore.swagger.io/v2/swagger.json"
  gwRestGen_isInsuranceSuite = "true"
}
  1. Update settings.gradle to include the client package to the build. You can configure multiple client packages, as shown in the following example. Respectively, you must configure the endpoint parameters for each package in build.gradle:

include 'claimcenter:v1'
include 'policycenter:v1'

Step 4: Build the client

The project provides Gradle task that you use to build the client. For details, see REST API client plugin tasks. In this project the code generation plugin generates a client against the PetStore service. Since the endpoint source is defined as an OpenAPI spec URL, you execute the following commands:

  1. Run the restDownload task to download the OpenAPI spec JSON file. To run a task with the wrapper, use one of the following commands from a Terminal window:

On Mac or Linux, run

./gradlew restDownload

On Windows:

gradlew restDownload

 

In IntelliJ, you can also run the restDownload task from Gradle task window.

Note: If you define the gwRestGen_endpoint_source as a relative path to a JSON file, the restDownload does not appear in the available tasks.

  1. Generate the client. To run a task with the wrapper, use one of the following commands from a Terminal window:

On Mac or Linux, run

./gradlew build

On Windows:

gradlew build

 

The build generates the client library <project>/endpoint/build/libs/gwgen.petstore-<version>.jar.

Step 5: Publish the Generated Client

To publish the client to the InsuranceSuite application run the publish task. To run a task with the wrapper, use one of the following commands from a Terminal window:

On Mac or Linux, run.

/gradlew publish

On Windows:

gradlew publish

In IntelliJ, you can also run the publish task from Gradle task window.

The task zips up the following libraries in build/distribution/endpoints-<version>.zip file:

  • The generated client <project>/endpoint/build/libs/gwgen.petstore-<version>.jar
  • The REST API client library /client/libs/client-<version>.jar
  • All libraries from /libs folder

Step 6: Deploy to InsuranceSuite application

  1. Stop the InsuranceSuite application
  2. Extract build/distribution/endpoints-<version>.zip to <IS>modules/configuration/plugins/shared/lib folder in an InsuranceSuite application installation
  3. Start the InsuranceSuite application

Step 7: Test the client in InsuranceSuite application

To test the client you create and run a test in Gosu Scratchpad in InsuranceSuite Studio. The test submits REST API requests to the PetStore service to get the store inventory and get information about the sold and available pets.

  1. Open InsuranceSuite Studio:
gwb studio
  1. To open Gosu scratchpad, click Tools → Gosu Scratchpad
  2. In Gosu scratchpad, type the following code:

uses gw.restclient.config.Config
uses gw.restclient.util.StaticMapper
uses gwgen.petstore.ApiClient
uses gwgen.petstore.api.StoreApi
uses gwgen.petstore.api.PetApi
uses gwgen.petstore.model.Pet
uses gwgen.petstore.model.Category
uses gwgen.petstore.model.Pet.StatusEnum

var mapper = StaticMapper.yaml()
var config = Config.builder().basePath(ApiClient.BASE_PATH).build()
var storeApi  = config.buildAPI(StoreApi)
var inv = storeApi.getInventory()

inv.forEach( \\ key, cnt -> print("${key} = ${cnt}"))
var petApi = config.buildAPI(PetApi)
var rtn = petApi.findPetsByStatus({ StatusEnum.AVAILABLE.toString(), 
                                    StatusEnum.SOLD.toString() })
print(mapper.writerWithDefaultPrettyPrinter().writeValueAsString(rtn))
  1. To run the code, click Run on the scratchpad navigation bar.
  2. The test completes and generates an output similar to the following output. The output below displays only part of the response:

"C:\\Program Files\\Java\\jdk1.8.0_152\\bin\\java.exe"
-javaagent:C:\\ClaimCenter\\studio\\sdk\\lib\\idea_rt.jar=50833:C:\\ClaimCenter\\studio\\sdk\\bin
-Dfile.encoding=UTF-8 -classpath C:\\Users\\user1\\AppData\\Local\\Temp\\classpath7313323.jar
gw.lang.Gosu "C:\\Users\\user1\\AppData\\Local\\Temp\\6dace4b4\\Gosu Scratchpad.gsp"
sold = 190
string = 292
pending = 182
availableTINFOILLLLLLLLLLLLLLLLLL....LLLLLLLLLLL = 1
available = 292
soldTINFOILLLLLLLLLLLLLLLLLL....LLLLLLLLLLL = 1
---
- id: 7777778888889957853
category:
name: "string"
name: "doggie"
photoUrls:
- "string"
tags:
- name: "string"
status: "available"
- id: 7777778888889957854
category:
name: "string"
name: "doggie"
photoUrls:
- "string"
tags:
- name: "string"
status: "available"
- id: 7777778888889957865
category:
name: "string"
name: "doggie"
photoUrls:
- "string"
tags:
- name: "string"
status: "available"
- id: 213124125
category:
id: 12
name: "cats"
name: "Garfield"
photoUrls: []
status: "available"
- id: 7777778888889957875
category:
name: "string"
name: "doggie"
photoUrls:
- "string"
tags:
- name: "string"
status: "available"
- id: 1234
category:
name: "string"
name: "casper"
photoUrls:
- "string"
tags:
- name: "string"
status: "available"
....
Process finished with exit code 0

You are now ready to use the Guidewire REST API Client to make calls to other services. For a more detailed explanation of the API client, client library, and client plugin, read the full documentation.

Related Info

Blog
Sr. Director of Product Management, Chris Vavra unveils new and future capabilities that make Guidewire integration projects simpler, faster, and easier.
Blog
Find training for the Guidewire Banff release for InsuranceSuite, Data, and Digital products from Guidewire. Get started now.
Cross-Platform Tool
Learn Gosu, the ubiquitous open-source programming language used in hundreds of P&C enterprises around the globe.

Don’t see what you are looking for?