/** * This file is auto generated from JavaDoc. Do not modify it manually. */ import type { Node } from "../../types/javax/jcr/Node"; import type { String } from "../../types/java/lang/String"; /** * Script utility for server-side invoke of the local * Sitevision REST API. * *

* This is a local, server-side, inbound utility to invoke the Sitevision REST API * of the local site without any outgoing http connections. * This utility can be used regardless of the REST API of the local site is enabled or not! *

* *

* Version note! External (http connection-based) invocations of the Sitevision REST API can specify different versions * (online / offline) via the URL. This inbound utility will always use current version as of * {@link senselogic.sitevision.api.versioning.VersionUtil#getCurrentVersion()}. *

* *

* Below are two typical examples of how to use the RestApi utility to execute a GET for the "nodes" endpoint on a given JCR Node * context and and process the returned javascript object. *

*

* a) Using a Node via a script variable (named "startPage") in the Sitevision Script module: *

*
   var restApi = require('RestApi'),
 *        result;
 *
 *    result = restApi.get(scriptVariables.startPage, 'nodes');
 *
 *    if (result.statusCode >= 200 && result.statusCode < 300) {
 *       out.println('Result: ' + JSON.stringify(result.body));
 *    } else {
 *       out.println('Fail: ' + result.statusMessage + '<br>' + JSON.stringify(result.body));
 *    }
*

* b) Using a Node via the app data (property "startPage") of a WebApp/RestApp: *

*
   ...
 *    result = restApi.get(appData.getNode('startPage'), 'nodes');
 *    ...
* *

* REST siblings note! *

* * @param script object * @author Magnus Lövgren * @since Sitevision 4.5 * @see VersionedRestApi * @see Requester * @see senselogic.sitevision.api.script.app.RestAppInvoker */ export interface RestApi { /** * Executes a GET endpoint of the REST API. * *

* REST hint! A get typically indicates a read of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @return a script object representing the response (properties: statusCode, statusMessage, body) */ get(aContextNode: Node, aOperationName: String | string): unknown; /** * Executes a GET endpoint of the REST API. * *

* REST hint! A get typically indicates a read of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationOptions the operation data/parameters * @return a script object representing the response (properties: statusCode, statusMessage, body) */ get( aContextNode: Node, aOperationName: String | string, aOperationOptions: unknown ): unknown; /** * Executes a GET endpoint of the REST API, targeting an instance of the context. * *

* REST hint! A get typically indicates a read of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationNode the operation Node of the context * @param aOperationOptions the operation data/parameters * @return a script object representing the response (properties: statusCode, statusMessage, body) */ get( aContextNode: Node, aOperationName: String | string, aOperationNode: Node, aOperationOptions: unknown ): unknown; /** * Executes a POST endpoint of the REST API. * *

* REST hint! A post typically indicates the creation of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationOptions the operation data/parameters * @return a script object representing the response (properties: statusCode, statusMessage, body) */ post( aContextNode: Node, aOperationName: String | string, aOperationOptions: unknown ): unknown; /** * Executes a PUT endpoint of the REST API. * *

* REST hint! A put typically indicates an update of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationOptions the operation data/parameters * @return a script object representing the response (properties: statusCode, statusMessage, body) * @since Sitevision 5 */ put( aContextNode: Node, aOperationName: String | string, aOperationOptions: unknown ): unknown; /** * Executes a PUT endpoint of the REST API, targeting an instance of the context. * *

* REST hint! A put typically indicates an update of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationNode the operation Node of the context * @param aOperationOptions the operation data/parameters * @return a script object representing the response (properties: statusCode, statusMessage, body) */ put( aContextNode: Node, aOperationName: String | string, aOperationNode: Node, aOperationOptions: unknown ): unknown; /** * Executes a DELETE endpoint of the REST API. * *

* REST hint! A delete typically indicates a removal of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @return a script object representing the response (properties: statusCode, statusMessage, body) * @since Sitevision 4.5.1 */ delete(aContextNode: Node, aOperationName: String | string): unknown; /** * Executes a DELETE endpoint of the REST API, targeting an instance of the context. * *

* REST hint! A delete typically indicates a removal of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationNode the operation Node of the context * @return a script object representing the response (properties: statusCode, statusMessage, body) */ delete( aContextNode: Node, aOperationName: String | string, aOperationNode: Node ): unknown; /** * Executes a DELETE endpoint of the REST API, targeting an instance of the context. * *

* REST hint! A delete typically indicates a removal of something. *

* @param aContextNode the endpoint context Node * @param aOperationName the endpoint operation name/method * @param aOperationNode the operation Node of the context * @param aOperationOptions the operation data/parameters * @return a script object representing the response (properties: statusCode, statusMessage, body) * @since Sitevision 2023.01.1 */ delete( aContextNode: Node, aOperationName: String | string, aOperationNode: Node, aOperationOptions: unknown ): unknown; } declare namespace RestApi {} declare var restApi: RestApi; export default restApi;