GithubHelp home page GithubHelp logo

psurti / irest4j Goto Github PK

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

REST client executing a connected sequence of calls by passing context

License: Apache License 2.0

Java 100.00%
rest client java

irest4j's Introduction

Java CI with Gradle CodeQL

iREST4j client

iREST4j ("interconnect REST") is a java tool that allows execution of a sequence of REST calls to a server. A REST sequence can be Login (OAuth/Basic Auth), GET (call to retrieve a list of items) and POST (call to update an item given parameters from the previous call). iREST4j inter-connects REST calls by passing extracted parameters from a previous call and provide variable subsititions on the following REST calls by sharing context in a sequence.

Features

  • Ability drive sequence of calls using property or YAML files
  • Ability to assign variables of extract data from responses using jsonPath expressions
  • Ability to substitute variables at runtime on other REST calls in the sequence
  • Ability to pass contextual data across REST calls.

TODOs

  • Support HTTPs
  • Support Branching

Getting Started

Building the project

The project uses gradle to build. Gradle version: 6.8.1 To build the project just run the following command:

gradlew clean bootJar run --args=src\main\resources\blog.properties
gradlew clean bootJar run --args=src\main\resources\blog.yaml -Dlogback.configurationFile=build\resources\main\logback.xml

Running the tool

java -jar irest4j-x.y.jar <path-to-properties-file>
# eg. java -jar build\libs\irest4j-1.0.jar build\resources\main\blog.properties

## To override logging level 
#  Change log level in logback.xml 
#  java -Dlogback.configurationFile=build\resources\main\logback.xml -jar build\libs\irest4j-1.0.jar build\resources\main\blog.properties

Configuration Properties

Global Level

Configuration can be specified using YAML or properties file. Please see blog.properties or blog.yaml for examples.

Property host is the URL used to identify the REST server.

Example:

host=https://httpbin.org:80

Property actions is a list of REST actions to execute in the order defined. The name of the actions are user-defined and must prefix with: "get" , "post" , "put" , "delete" , or "form". The prefixes "get", "post", "put", "delete" map to HTTP GET, HTTP POST, HTTP PUT and HTTP DELETE operations respectively. Prefix "form" is for form-based POST requests that does "application/x-www-form-url-encoded" encoding automatically. A built-in "login" action is also supported that enables OAuth and Basic Authentication using authorization "Bearer" and "Basic" headers.

Example:

actions=login,getAllItems,putItem

Property pretty outputs JSON responses in a well-indented format. The valid values are true or false (default).

Example:

pretty=true

Property ctx is an application context used for assigning constant values to user-defined variable names. Using format "{{ .. }}", these variables are substituted on request calls.

There is also a built-in variable part of the context such as: "ctx.seq.id ": This is an auto-sequence generated number for unique identifiers during request calls.

Example:

ctx.foo=bar 
ctx.page=5
getBlogPosts.path=/posts/{{ctx.seq.id}}

Request/Response Level

For each REST action in the actions list above, these properties are specific to the endpoint:

Property path represents a static of dynamic URI endpoint to call. Additionally, URI can have parameters. Variables are dynamically substituted.

Example:

getItem.path=/items/{{item.id}}
getItem.path=/items/10

Property jsonPath.{user-defined variable name} evaluates JsonPath expression and assign to the user-defined variable. Variables can have multiple dot notations, as shown in the examples. Please refer to JsonPath expressions for more information.

Example:

getAllItems.jsonPath.userId=$[?(@.title == 'laboriosam dolor voluptates')].userId 
getAllItems.jsonPath.user.id=$..id

Property encodeUrl performs URI encoding on the entire URL. It can be enabled/disabled by setting true or false (default) respectively.

Example:

postNewBlog.encodeUrl=true

Other tools

https://github.com/Kortex/jrest-client/

irest4j's People

Contributors

psurti 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.