### Start Opscotch Agent (Windows Batch) Source: https://docs.opscotch.co/docs/introduction/getting-started-full Command to start the opscotch agent on Windows. It requires specific arguments generated by the test runner, which include the path to the test runner bootstrap and a private key. ```batch opscotch-agent.exe ``` -------------------------------- ### Start the Opscotch Agent Source: https://docs.opscotch.co/docs/introduction/getting-started-full Launches the agent process using the generated bootstrap configuration file. ```bash ./opscotch-agent configs/weather/weather.bootstrap.json ``` ```powershell opscotch-agent.exe configs/weather/weather.bootstrap.json ``` -------------------------------- ### Start Opscotch Agent (Linux/macOS Shell) Source: https://docs.opscotch.co/docs/introduction/getting-started-full Command to start the opscotch agent on Linux/macOS. It requires specific arguments generated by the test runner, which include the path to the test runner bootstrap and a private key. ```shell ./opscotch-agent ``` -------------------------------- ### Bootstrap Keys Configuration Example Source: https://docs.opscotch.co/blog/crypto-context Provides an example of how to configure bootstrap keys in an array format. This allows preloading keys for the agent and workflows at startup, specifying their ID, purpose, type, and hex-encoded key material. ```json [ { "id": "signing-secret", "purpose": "sign", "type": "secret", "keyHex": "ABCDEF..." }, { "id": "signing-public", "purpose": "sign", "type": "public", "keyHex": "123456..." } ] ``` -------------------------------- ### Start OpScotch Agent Source: https://docs.opscotch.co/docs/introduction/getting-started Commands to launch the agent process, with syntax variations for Unix-based systems and Windows. ```bash opscotch-agent configs/test.bootstrap.json ``` ```powershell opscotch-agent.exe test.bootstrap.json ``` -------------------------------- ### Trigger Configuration for One-Time Execution Source: https://docs.opscotch.co/docs/introduction/getting-started-further Provides an example of configuring a trigger to execute a workflow only once when the agent starts up. This is achieved by setting the 'runOnce' property to true. ```json { "runOnce" : true } ``` -------------------------------- ### Bootstrap Configuration Setup Source: https://docs.opscotch.co/docs/introduction/getting-started Defines the structure of the test.bootstrap.json file, which includes remote configuration paths, deployment IDs, and agent private keys. ```json [ { "remoteConfiguration": "configs/test.config", "deploymentId": "opscotch-examples", "agentPrivateKey": "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBT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lzcm5VUEhkMEU2WEcxUzZwUTVZVExzQXJscmtBZzBScGIzTDkKVDBYWW03MFprYy81WGZuOVNFd0dEV0k9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0" } ] ``` -------------------------------- ### MockHttpResponse Return File Example Source: https://docs.opscotch.co/docs/apireference Example of specifying a file to return as the response for a mock HTTP request. ```json { "returnThisFile" : "test.response.summary.json" } ``` -------------------------------- ### Run Opscotch Agent with Encrypted Bootstrap Source: https://docs.opscotch.co/docs/administrating/packaging Starts the Opscotch agent by providing the encrypted bootstrap file and the corresponding decryption key. ```bash opscotch-agent bootstrap.packaged ``` ```batch opscotch-agent.exe bootstrap.packaged ``` -------------------------------- ### Agent Heartbeat Workflow Example Source: https://docs.opscotch.co/docs/administrating/monitoring This example demonstrates how to configure an agent heartbeat using a scripted workflow step in opscotch. It sends a 'heartbeat' metric every 60 seconds. This is useful for monitoring agent availability. ```json { "workflows": [ { "enabled": true, "name": "Agent Heart Beat", "steps": [ { "enabled": true, "type": "scripted", "stepId": "heartbeat", "trigger" : { "timer" : { "period" : 60000 } }, "resultsProcessor": { "script": "context.sendMetric('heartbeat', 1.0)" } } ] } ] } ``` -------------------------------- ### Reusing Processor Resources Source: https://docs.opscotch.co/docs/workflow Example of defining multiple steps that share the same processor resource file while providing different data configurations for each instance. ```json { "steps" : [ { "stepId" : "call-example-1", "urlGenerator" : { "resource" : "set-url.js" }, "data" : { "host-ref" : "example", "path" : "/this/is/a/url", "httpMethod" : "POST" } }, { "stepId" : "call-example-2", "urlGenerator" : { "resource" : "set-url.js" }, "data" : { "host-ref" : "example", "path" : "/yet/another/url", "httpMethod" : "PUT" } } ] } ``` -------------------------------- ### MockHttpResponse Expected Headers Example Source: https://docs.opscotch.co/docs/apireference Example of setting expected headers for a mock HTTP response. ```json { "expectedHeaders" : {"some": ["thing"] } } ``` -------------------------------- ### MockHttpResponse Delay Example Source: https://docs.opscotch.co/docs/apireference Example of configuring a delay for a mock HTTP response. ```json { "delay" : 0 } ``` -------------------------------- ### MockHttpResponse Mocked Headers Example Source: https://docs.opscotch.co/docs/apireference Example of setting mocked headers to be returned with a mock HTTP response. ```json { "mockedHeaders" : { "Set-Cookie": ["JSESSIONID=A","X-CSRF-TOKEN=B"] } } ``` -------------------------------- ### Start Opscotch Packager via Docker Source: https://docs.opscotch.co/blog/packaging This command launches the Opscotch packager container, mapping the required local resource directories to the container's internal paths. It exposes the API on port 39575 for subsequent packaging operations. ```bash docker run \ -p 39575:39575 \ -v "/resources:/opscotch-community-resources" \ -v "/path/to/local-resources-1:/local-resources1" \ -v "/path/to/local-resources-2:/local-resources2" \ ghcr.io/opscotch/opscotch-packager-standalone:latest ``` -------------------------------- ### Execute API Call using PowerShell (Windows) Source: https://docs.opscotch.co/docs/introduction/getting-started-full This snippet shows how to set environment variables for the OpenWeatherMap API key and city name using PowerShell, and then use Invoke-WebRequest to fetch data from the API. This is the Windows equivalent of the cURL example. ```powershell $env:OPENWEATHERMAP_KEY = 'a83da2d308613877a88910dce9568dd5' $env:CITY_NAME = 'Wellington' Invoke-WebRequest -Uri "https://api.openweathermap.org/data/2.5/weather?units=metric&q=$env:CITY_NAME&appid=$env:OPENWEATHERMAP_KEY" ``` -------------------------------- ### Compress and Decompress Data Source: https://docs.opscotch.co/blog/byte-manipulation Provides examples of using built-in Gzip and Zip compression utilities on buffer handles. ```javascript let textBuf = byteContext.createFromString("repeat me ".repeat(50)); let gz = byteContext.gzip(textBuf); let restored = byteContext.gunzip(gz); // ZIP alternative let zipped = byteContext.zip(textBuf); let unzipped = byteContext.unzip(zipped); ``` -------------------------------- ### Example OpenWeatherMap API Response (Simplified) Source: https://docs.opscotch.co/docs/introduction/getting-started-full A simplified JSON response from the OpenWeatherMap API, showing the temperature within the 'main' object and the timestamp ('dt'). This is a subset of the full response. ```json { "main": { "temp": 21.55 }, "dt": 1560350645, "name": "Wellington" } ``` -------------------------------- ### Fire-and-Forget Send to Step with Headers (JavaScript) Source: https://docs.opscotch.co/blog/send-to-step This example shows how to use `sendToStepAndForget` to initiate a process in another step without waiting for its completion. This is useful for asynchronous tasks where the result is not immediately needed. Headers can be included in the request. ```javascript context.sendToStepAndForget("ingest-step", "payload", { "source": "batch-42" }); // continue immediately; no returned context ``` -------------------------------- ### Execute API Call using cURL (Linux/macOS) Source: https://docs.opscotch.co/docs/introduction/getting-started-full This snippet demonstrates how to set environment variables for the OpenWeatherMap API key and city name, and then use cURL to make an HTTP GET request to the API. It's a common way to test API endpoints from the command line. ```bash export OPENWEATHERMAP_KEY=a83da2d308613877a88910dce9568dd5 export CITY_NAME=Wellington curl "https://api.openweathermap.org/data/2.5/weather?units=metric&q=$CITY_NAME&appid=$OPENWEATHERMAP_KEY" ``` -------------------------------- ### Bootstrap: AllowExternalHostAccess Configuration Example Source: https://docs.opscotch.co/docs/apireference Illustrates how to define access permissions for external HTTP(S) services that workflows can call. This includes specifying host URLs, headers, allowed HTTP methods and URI patterns, and custom data. ```json { "allowExternalHostAccess": [ { "id" : "myHost", "host": "https://www.example.com", "headers": { "Content-Type": "application/json;charset=UTF-8", "Accept": "application/json, text/plain, *\/*" }, "allowList" : [ { "method" : "GET", "uriPattern" : "/this/is/allowed.*"}, { "method" : "POST", "uriPattern" : "/this/.*\/allowed"} ], "data" : { } } ] } ``` -------------------------------- ### Configure HTTP Server Source: https://docs.opscotch.co/docs/apireference Defines parameters for starting an HTTP server, including binding address, port, and optional static asset serving from packaged zip files. This is used to bootstrap internal HTTP triggers. ```JSON { "bindAddress": "127.0.0.1", "id": "myAPI", "port": 1234, "serveFromPackagedAsset": {} } ``` -------------------------------- ### Call Another Step Using context.sendToStep Source: https://docs.opscotch.co/docs/workflow Demonstrates how to call another step from a processor using the `context.sendToStep` method. This is akin to calling a function, allowing data to be passed to the next step. The example shows a JSON structure defining steps and their processors, with one processor invoking `stepTwo`. ```json { "steps": [ { "stepId": "stepOne", "resultsProcessor": { "processors": [ { "script": "console.log('this is stepOne')" }, { "script": "context.sendToStep('stepTwo', 'message')" } ] } }, { "stepId": "stepTwo", "resultsProcessor": { "script": "console.log('this is stepTwo')" } } ] } ``` -------------------------------- ### Get Message Body As String API Source: https://docs.opscotch.co/docs/apireference Get the current message body. This could be the response from an HTTP call, for example. ```APIDOC ## GET /websites/opscotch_co/getMessageBodyAsString ### Description Get the current message body. This could be the response from an HTTP call, for example. ### Method GET ### Endpoint `/websites/opscotch_co/getMessageBodyAsString` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **messageBody** (String) - The current message body. #### Response Example ```json { "messageBody": "The response content." } ``` ``` -------------------------------- ### Curl Example for Multipart Upload Source: https://docs.opscotch.co/blog/multipart-http-uploads This `curl` command demonstrates how to send a multipart HTTP request with both a JSON payload in the 'body' field and a binary file in the 'stream' field. It specifies the content type for the binary file. ```bash curl "http://localhost:11000/upload" \ -X POST \ -F 'body={"version": "2.0", "method": "initialize"}' \ -F 'stream=@a-binary-file;type=application/octet-stream' ``` -------------------------------- ### Get and Set Step Properties (JavaScript) Source: https://docs.opscotch.co/docs/apireference Retrieves the set properties for the current step. These properties persist across requests but not across configuration reloads or restarts. The example shows how to put a property with a key-value pair. ```javascript property = context.getStepProperties().put("myProperty", "ok"); ``` -------------------------------- ### Get Property API Source: https://docs.opscotch.co/docs/apireference Gets a property from this running context. ```APIDOC ## GET /websites/opscotch_co/getProperty/{key} ### Description Gets a property from this running context. ### Method GET ### Endpoint `/websites/opscotch_co/getProperty/{key}` ### Parameters #### Path Parameters - **key** (String) - Required - The key of the property to get. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **propertyValue** (Object) - The property value associated with the key. #### Response Example ```json { "propertyValue": "some property value" } ``` ``` -------------------------------- ### Get Persisted Item API Source: https://docs.opscotch.co/docs/apireference Gets an item from the step's persistence. ```APIDOC ## GET /websites/opscotch_co/getPersistedItem/{key} ### Description Gets an item from the step's persistence. ### Method GET ### Endpoint `/websites/opscotch_co/getPersistedItem/{key}` ### Parameters #### Path Parameters - **key** (String) - Required - The key of the item to retrieve. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **item** (String) - The string value of the persisted item. #### Response Example ```json { "item": "persisted data" } ``` ``` -------------------------------- ### Execute Workflow Packaging Source: https://docs.opscotch.co/docs/introduction/getting-started Command line instructions to package the configuration using the OpScotch packager utility, supporting both Unix-based and Windows environments. ```bash cat configs/test.config.json | opscotch-packager workflow configs/test.package.config.json > configs/test.config ``` ```batch type configs/test.config.json | opscotch-packager.exe workflow configs/test.package.config.json > configs/test.config ``` -------------------------------- ### Curl Example for Single-Part Binary Upload Source: https://docs.opscotch.co/blog/multipart-http-uploads This `curl` command shows how to upload a single binary file using an HTTP POST request. It sets the `Content-Type` to `application/octet-stream` and uses `--binary-data` to send the file content. ```bash curl "http://localhost:11000/upload" \ -X POST \ -H "Accept: application/json" \ -H "Content-Type: application/octet-stream" \ --binary-data '@a-binary-file' ``` -------------------------------- ### Get Passed Message As String API Source: https://docs.opscotch.co/docs/apireference Get the message body that was passed to this step. ```APIDOC ## GET /websites/opscotch_co/getPassedMessageAsString ### Description Get the message body that was passed to this step. ### Method GET ### Endpoint `/websites/opscotch_co/getPassedMessageAsString` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **passedMessage** (String) - The message body that was passed to this step. #### Response Example ```json { "passedMessage": "The input message." } ``` ``` -------------------------------- ### Global Configuration via Bootstrap Data Source: https://docs.opscotch.co/docs/introduction/getting-started-full Demonstrates moving data objects to the Bootstrap level to allow inheritance and reuse across multiple workflows. ```json { "allowExternalHostAccess" : [ { "id" : "openweathermap", "host" : "http://mockserver", "allowList" : [ { "method" : "GET", "uriPattern" : "/data/2.5/weather"} ] } ], "data" : { "cityname" : "Wellington", "appid" : "1234" } } ``` -------------------------------- ### MockHttpResponse Expected Payload Example Source: https://docs.opscotch.co/docs/apireference Example of setting an expected payload for a mock HTTP response. ```json { "expectedPayload": "{\"some\":\"thing\"}" } ``` -------------------------------- ### Run the Opscotch Packager Source: https://docs.opscotch.co/docs/introduction/getting-started-full Processes the workflow configuration through the packager to generate the final deployment configuration file. ```bash cat configs/weather/weather.config.json | ./opscotch-packager workflow configs/weather/weather.package.config.json > configs/weather/weather.config ``` ```powershell type configs/weather/weather.config.json | opscotch-packager.exe workflow configs/weather/weather.package.config.json > configs/weather/weather.config ``` -------------------------------- ### Configuring Processors with Data Properties Source: https://docs.opscotch.co/docs/workflow Shows how to define configuration parameters within a step and retrieve them inside a processor script. This approach replaces hard-coded values with dynamic data inputs. ```json { "stepId" : "call-example", "urlGenerator" : { "resource" : "set-url.js" }, "data" : { "host-ref" : "example", "path" : "/this/is/a/url", "httpMethod" : "POST" } } ``` ```javascript hostref = context.getData("host-ref"); path = context.getData("path"); method = context.getData("httpMethod"); context.setUrl(hostref, path); context.setHttpMethod(method); ``` -------------------------------- ### Get Authentication Properties From Step API Source: https://docs.opscotch.co/docs/apireference Gets the authentication properties from another step. These properties can expire. ```APIDOC ## GET /websites/opscotch_co/getAuthenticationPropertiesFromStep/{stepId}/{key} ### Description Gets the authentication properties from another step. These properties can expire. ### Method GET ### Endpoint `/websites/opscotch_co/getAuthenticationPropertiesFromStep/{stepId}/{key}` ### Parameters #### Path Parameters - **stepId** (String) - Required - The ID of the step to fetch the property from. - **key** (String) - Required - The property key to fetch. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **properties** (String) - JSON string of authentication properties value, or null if expired. #### Response Example ```json { "properties": "{\"authKey\": \"someValue\"}" } ``` ``` -------------------------------- ### JavascriptSource Configuration with Multiple Processors Source: https://docs.opscotch.co/docs/introduction/getting-started-further Illustrates how to execute multiple JavaScript scripts sequentially using the 'processors' array within a JavascriptSource configuration. Each processor references a resource file. ```json { "payloadGenerator" : { "processors": [ { "resource" : "..." }, { "resource" : "..." } ] } } ``` -------------------------------- ### Configure HTTP Listener for Static Assets Source: https://docs.opscotch.co/blog/serve-static-content Sets up an HTTP listener in the bootstrap that links to a previously defined packaged asset ID to serve static content. ```json { "allowHttpServerAccess": [ { "id": "myStaticServer", "port": 12345, "serveFromPackagedAsset": { "packagedAssetFileId": "myStaticContent" } } ] } ``` -------------------------------- ### Get Header API Source: https://docs.opscotch.co/docs/apireference Get a header from the previous request/response. Note: it always returns a JSON array string. ```APIDOC ## GET /websites/opscotch_co/getHeader/{name} ### Description Get a header from the previous request/response. Note: it always returns a JSON array string. ### Method GET ### Endpoint `/websites/opscotch_co/getHeader/{name}` ### Parameters #### Path Parameters - **name** (String) - Required - The name of the header to get. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **headerValue** (String) - The header value as a JSON array string, or an empty array string. #### Response Example ```json { "headerValue": "[\"value1\", \"value2\"]" } ``` ``` -------------------------------- ### MockHttpResponse Return Status Code Example Source: https://docs.opscotch.co/docs/apireference Example of setting the status code to be returned by a mock HTTP response. ```json { "returnThisStatusCode" : 302 } ``` -------------------------------- ### Configuring Workflow with External Resource Files Source: https://docs.opscotch.co/docs/introduction/getting-started-full Shows how to reference an external JavaScript file for URL generation and structure the workflow configuration. ```json { "workflows": [ { "name" : "Current Temperature", "steps" : [ { "type": "scripted", "stepId": "current-temperature", "urlGenerator" : { "resource" : "weather/weather-urlgenerator.js", "data" : { "cityname" : "Wellington", "appid" : "1234" } }, "resultsProcessor" : { "resource" : "weather/weather-resultsprocessor.js" } } ] } ] } ``` -------------------------------- ### Execute Test Runner (Shell) Source: https://docs.opscotch.co/docs/introduction/getting-started-full These commands show how to run the Opscotch test runner on Linux/macOS and Windows systems, using a specified test runner configuration file. ```shell ./opscotch-testrunner tests/testrunner.config.json ``` ```shell opscotch-testrunner.exe tests/testrunner.config.json ``` -------------------------------- ### Bootstrap Configuration File Source: https://docs.opscotch.co/docs/introduction/getting-started-full A JSON file defining the bootstrap parameters for the agent, including remote configuration paths, deployment IDs, and external host access rules. ```json [ { "remoteConfiguration" : "configs/weather/weather.config", "deploymentId" : "weather-examples", "agentPrivateKey" : "LS0tLS1CRUdJTiBQUklWQVRFIEtFWS0tLS0tCk1JSUV2UUlCQURBTkJna3Fo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UEhkMEU2WEcxUzZwUTVZVExzQXJscmtBZzBScGIzTDkKVDBYWW03MFprYy81WGZuOVNFd0dEV0k9Ci0tLS0tRU5EIFBSSVZBVEUgS0VZLS0tLS0K", "allowExternalHostAccess" : [ { "id" : "openweathermap", "host" : "https://api.openweathermap.org", "allowList" : [ { "method" : "GET", "uriPattern" : "/data/2.5/weather"} ] } ], "data" : { "cityname" : "Wellington", "appid" : "a83da2d308613877a88910dce9568dd5" } } ] ``` -------------------------------- ### Configure Weather Workflow (JSON) Source: https://docs.opscotch.co/docs/introduction/getting-started-full This JSON configuration sets up a workflow named 'Current Temperature' within the opscotch framework. It includes a scripted step that triggers every 60 seconds, with placeholders for URL generation and results processing. ```json { "workflows": [ { "name" : "Current Temperature", "steps" : [ { "type" : "scripted", "stepId" : "current-temperature", "trigger" : { "timer" : { "period" : 60000 } }, "urlGenerator" : { "script" : "" }, "resultsProcessor" : { "script" : "" } } ] } ] } ``` -------------------------------- ### Convert data formats with ByteContext Source: https://docs.opscotch.co/blog/crypto-context Demonstrates how to manipulate buffer handles by converting between strings, hexadecimal representations, and binary data. ```javascript let payload = byteContext.createFromString("payload"); let payloadHex = byteContext.binaryToHex(payload); let fromHex = byteContext.hexToBinary(payloadHex); ``` -------------------------------- ### Get Data API Source: https://docs.opscotch.co/docs/apireference Retrieves data associated with the current step. ```APIDOC ## GET /websites/opscotch_co/getData ### Description Retrieves the JSON string for the data for this step. ### Method GET ### Endpoint `/websites/opscotch_co/getData` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **data** (String) - The JSON string for the data for this step. #### Response Example ```json { "data": "{\"key\": \"value\"}" } ``` ## GET /websites/opscotch_co/getData/{key} ### Description Retrieves the string value for a specific key from the step's data. ### Method GET ### Endpoint `/websites/opscotch_co/getData/{key}` ### Parameters #### Path Parameters - **key** (String) - Required - The key of the data to retrieve. #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **value** (String) - The string value associated with the key. #### Response Example ```json { "value": "some data" } ``` ``` -------------------------------- ### Set URL and HTTP Method Source: https://docs.opscotch.co/docs/workflow Shows multiple approaches to setting both the URL and HTTP method, including inline script chaining, processor arrays, and external resource file references. ```json { "stepId": "call-example", "urlGenerator": { "script": "context.setUrl('example', '/this/is/a/url'); context.setHttpMethod('POST')" } } ``` ```json { "stepId": "call-example", "urlGenerator": { "processors": [ { "script": "context.setUrl('example', '/this/is/a/url')" }, { "script": "context.setHttpMethod('POST')" } ] } } ``` ```javascript context.setUrl('example', '/this/is/a/url'); context.setHttpMethod('POST'); ``` ```json { "stepId": "call-example", "urlGenerator": { "resource": "set-url.js" } } ``` -------------------------------- ### Get Body API Source: https://docs.opscotch.co/docs/apireference A shorthand for: check `getMessageBodyAsString()` then check `getPassedMessageAsString()`. ```APIDOC ## GET /websites/opscotch_co/getBody ### Description A shorthand for: check `getMessageBodyAsString()` then check `getPassedMessageAsString()`. ### Method GET ### Endpoint `/websites/opscotch_co/getBody` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **body** (String) - The contents either passed into the step or set by the step. #### Response Example ```json { "body": "This is the message body." } ``` ``` -------------------------------- ### GET /health Source: https://docs.opscotch.co/blog/packaging Performs a simple health check on the packager application. ```APIDOC ## GET /health ### Description Provides a simple health check for the packager application. ### Method GET ### Endpoint `/health` ### Parameters None ### Request Example ```bash curl http://localhost:39575/health ``` ### Response #### Success Response (200) - **status** (string) - Indicates the health status (e.g., "OK"). #### Response Example ```json { "status": "OK" } ``` ``` -------------------------------- ### Get All Errors API Source: https://docs.opscotch.co/docs/apireference Retrieves a list of all error messages associated with the current context. ```APIDOC ## GET /websites/opscotch_co/getAllErrors ### Description Retrieves a list of all error messages associated with the current context. ### Method GET ### Endpoint `/websites/opscotch_co/getAllErrors` ### Parameters None ### Request Example None ### Response #### Success Response (200) - **errors** (List of String) - A list of error messages, or an empty list if no errors are present. #### Response Example ```json { "errors": [ "Error message 1", "Error message 2" ] } ``` ``` -------------------------------- ### Packaging Configuration File Source: https://docs.opscotch.co/docs/introduction/getting-started-full A JSON configuration file used by the packager to define license paths, public keys, and resource directories. ```json { "license" : "configs/license.txt", "agentPublicKey" : "configs/agent.public.key", "resourceDirs" : ["resources"] } ``` -------------------------------- ### Configure Host Reference Source: https://docs.opscotch.co/docs/workflow Defines the bootstrap host reference configuration required for the context.setUrl method to resolve base URLs. ```json { "hosts": { "example": { "host": "https://www.example.com" } } } ``` -------------------------------- ### Configure HTTP Request Method Source: https://docs.opscotch.co/docs/apireference Sets the HTTP method for the HttpRequestTrigger to listen for. Defaults to 'GET'. ```json { "method": "POST" } ``` -------------------------------- ### Create and Combine Buffers with ByteContext Source: https://docs.opscotch.co/blog/byte-manipulation Demonstrates how to initialize buffers from strings or byte arrays and concatenate them into a single buffer handle. ```javascript // UTF-8 from string let text = "Hello opscotch"; let textBuf = byteContext.createFromString(text); // From bytes let header = byteContext.createFromByteArray([0xAA, 0xBB]); // Concatenate let packet = byteContext.concat([header, textBuf]); ``` -------------------------------- ### Get First Error API Source: https://docs.opscotch.co/docs/apireference Retrieves the first error message from a given list of errors, if available. ```APIDOC ## POST /websites/opscotch_co/getFirstError ### Description Retrieves the first error message from a given list of errors, if available. ### Method POST ### Endpoint `/websites/opscotch_co/getFirstError` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **errors** (List of String) - Required - The list of error messages to retrieve the first error from. ### Request Example ```json { "errors": [ "Error 1", "Error 2" ] } ``` ### Response #### Success Response (200) - **error** (String) - The first error message if the list is not empty, or null if the list is empty or null. #### Response Example ```json { "error": "Error 1" } ``` ``` -------------------------------- ### POST /build-workflows Source: https://docs.opscotch.co/blog/packaging Builds a workflow by including and customizing multiple workflow files based on a provided manifest. ```APIDOC ## POST /build-workflows ### Description Builds a workflow from a manifest that includes and customizes multiple workflow files. ### Method POST ### Endpoint `/build-workflows` ### Parameters #### Request Body - **manifest** (object) - Required - The manifest file defining the workflow structure and components. - **[fields]** (any) - Description of fields within the manifest would go here, depending on its structure. ### Request Example ```json { "manifest": { "workflowName": "MyCustomWorkflow", "components": [ { "type": "workflow", "source": "/path/to/base/workflow.yaml" }, { "type": "config", "source": "/path/to/custom/config.json" } ] } } ``` ### Response #### Success Response (200) - **workflowId** (string) - An identifier for the newly built workflow. - **status** (string) - The status of the workflow build process. #### Response Example ```json { "workflowId": "wf_abc123", "status": "completed" } ``` ``` -------------------------------- ### Get All Errors Source: https://docs.opscotch.co/docs/apireference Retrieves a list of all error messages associated with the current context. Returns an empty list if no errors are present. ```java getAllErrors() ``` -------------------------------- ### Configuring Global Host Headers Source: https://docs.opscotch.co/docs/workflow Define headers within the bootstrap file's host section to automatically apply them to every request made to a specific host. ```json { "myHost": { "host": "https://example.com", "headers": { "Content-Type": "application/json" } } } ``` -------------------------------- ### Set URL via Processor Script Source: https://docs.opscotch.co/docs/workflow Demonstrates using the urlGenerator processor with an inline script to set the target URL using the context object. ```json { "stepId": "call-example", "urlGenerator": { "script": "context.setUrl('example', '/this/is/a/url')" } } ``` -------------------------------- ### JavascriptSource Configuration with Resource File Source: https://docs.opscotch.co/docs/introduction/getting-started-further Demonstrates how to configure a JavascriptSource to use an external JavaScript resource file. This is the most common method for including scripts in workflows. ```json { "payloadGenerator" : { "resource" : "..." } } ``` -------------------------------- ### Get First Error from List Source: https://docs.opscotch.co/docs/apireference Extracts the first error message from a provided list of strings. Returns `null` if the list is empty or null. ```java getFirstError(List of java.lang.String errors) ```