0.2.0 • Published 2 years ago

rest-harness-client v0.2.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

This software is the sole property of Prime Solutions Group, Inc.

Project Title:

REST Harness NodeJS Client

REST Harness is a tool to stand in the place of another REST service. This can be used to Mock out a service that doesn't exist yet, or where we need to reproduce a particular set of inputs from an opaque service. It can also serve as a simple shared cache. This library contains a client that can be used to interact with the REST Harness web server.

Getting Started:

Requirements/Built with: Node v16.0+ fetch

Import

Usage: import NodeClient from rest-harness-client client = new NodeClient("base url")

Methods

(Subject to change)

create_path(path, rc=200, return_value="No data provided.", delay=0, header={"Content-Type": "application/json"})

Parameters:

path : required, specifies the path of the endpoint you would like to create rc : optional, specifies the return code you would like to receive upon hitting the created endpoint return_value : optional, specifies the value you would like to return from the created endpoint delay : optional, can be used to force an endpoint to wait for a specified amount of time before returning its contents.(useful for mimicking a bad connection) header : optional, can be used to specify custom headers for your endpoint responses

Description

Creates an endpoint on a REST Harness web server given parameters as information

Examples:

client.create_path("/test", 200, "test data") Creates an endpoint at /test that returns "test data" upon access. client.create_path("/test", 203, {"prop1" : "value1", "prop2" : "value2"}, 3) Creates an endpoint at /test that returns the provided JSON data after a 3 second delay upon access.

create_paths(paths)

Parameters:

paths : required, contains all data of each path you would like to create in a JSON object, list, or other compatible data structure

Description:

Creates multiple endpoints given a list of endpoints and their parameters.

Examples:

client.create_paths({"/path1" : {"delay" : 0, "rc" : 200, "return_value" : "test test"}, "/path2" : {"delay" : 0, "rc" : 204, "return_value" : "test test"}, "/path3" : {"delay" : 2, "rc" : 200, "return_value" : "returned something"}, "/path4" : {"delay" : 1, "rc" : 202, "return_value" : "test something"},}) Creates 4 endpoints: /path1, /path2, /path3, and /path4 which return their corresponding return codes and return values after a given delay.

get_path(path)

Parameters:

path : required, specifies the path of the endpoint you would like to get data from

Description:

Hits an endpoint and returns the information associated with it.

Examples:

client.create_path("/test", 200, "test data") ...(some code) client.get_path("/test") Creates an endpoint at /test, then hits the endpoint and returns "test data" upon access.

client.create_path("/test", 203, {"prop1" : "value1", "prop2" : "value2"}, 3) ...(some code) client.get_path("/test") Creates an endpoint at /test, then hits the endpoint and returns the JSON return value after a 3 second delay.

get_all()

Parameters

N/A

Description:

Gets all information from all created paths and returns it in a JSON format.

Examples:

client.create_path("/test", 200, "test data") client.create_path("/test2", 203, {"prop1" : "value1", "prop2" : "value2"}, 3) ...(some code) client.get_path("/test") Creates an endpoint at /test and /test2, then gets all information associated with both endpoints(no programmable delay) as a JSON object.

update_path(path, rc=200, return_value="No data provided.", delay=0, header={"Content-Type": "application/json"})

Parameters:

path : required, specifies the path of the endpoint you would like to update rc : optional, specifies the return code you would like to receive upon hitting the updated endpoint return_value : optional, specifies the value you would like to return from the updated endpoint delay : optional, can be used to force an endpoint to wait for a specified amount of time before returning its contents.(useful for mimicking a bad connection) header : optional, can be used to specify custom headers for your endpoint responses

Description

Updates an endpoint on a REST Harness web server given parameters as information

Examples:

client.create_path("/test", 200, "test data") client.update_path("/test", 203, {"prop1" : "value1", "prop2" : "value2"}, 3) Creates an endpoint at /test, then updates its return value and return code so that it returns different values when hit

delete_path(path)

Parameters:

path : required, specifies the path of the endpoint you would like to delete

Description

Deletes an endpoint on a REST Harness web server given a path as a parameter

Examples:

client.create_path("/test", 200, "test data") ...(some code) client.delete_path("/test") Deletes the /test endpoint from the REST Harness server.

Notes:

To be determined at a later date.

0.2.0

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago