# Implementation of simple algorithms Simple algorithms can be implemented using a generic unix docker image, and totally defined in the json script. Examples of this algorithms are parametric `curl` or `wget` operations on external APIs, shell for file processing, etc ### Default ccpimage for simple algorithms To implement methods that doesn't need any particular library or configuration, we can leave empty the `ccpimage` value, to use a basic Linux Docker image. ![ccpimage bash](./imgs/input_ccpimage_bash.png) ```json { "inputs": { "ccpimage": { "id": "ccpimage", "title": "Runtime", "description": "`bash`, a basic unix docker image.", "minOccurs": 1, "maxOccurs": 1,Bash "schema": { "type": "string", "format": "url", "contentMediaType": "text/plain", "default": "", "readOnly": true } } } } ``` ### Execution Parameters all the parameters and configurations needed for the execution of the algorithms are defined in the inputs section ```json { "inputs": { "baseurl": { "id": "baseurl", "title": "Base URL", "description": "The base URL of the REST API", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": "url", "contentMediaType": "text/plain", "default": "https://REST_API_URL/process/", "readOnly": true } }, "service": { "id": "service", "title": "Service name", "description": "The name of the service", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": null, "contentMediaType": "text/plain", "default": "my_custom_service" } }, "file": { "id": "file", "title": "Input file", "description": "The input file to be annotated", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": "file", "contentMediaType": "text/plain", "default": "" } }, "contenttype": { "id": "contenttype", "title": "Content type", "description": "The content type of the input file", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": null, "contentMediaType": "text/plain", "default": "text/plain", "enum": [ "text/plain", "application/pdf", "text/html" ] } }, "credentials": { "id": "credentials", "title": "Credentials", "description": "The Basic auth credentials", "minOccurs": 1, "maxOccurs": 1, "schema": { "type": "string", "format": "secret", "contentMediaType": "text/plain", "default": "XXXYYYZZZ" } } } } ``` the "readOnly": true/false parameter defines what is binded in the definiton of the ccp method (readonly=true, only the `baseurl` input in the given example) and what is parametric (readonly=false, or not defined in the input schema) the given example uses special input parameters that will be explained in next sections * [credentials](./credentials.md) ![secret input credentials](./imgs/input_secret_credentials.png) * [file upload](./input_file.md) ![secret file](./imgs/input_file.png) ### Execution the implementation of the algorithms is totally defined in the deploy-script and in the execute-script ```json { "additionalParameters": { "parameters": [ { "name": "deploy-script", "value": [ "echo {{file}} | base64 -d > /ccp_data/input" ] }, { "name": "execute-script", "value": [ "wget {{baseurl}}/{{service}}?annotations={{annotations}} --post-file /ccp_data/input --header \"Authorization: Basic {{credentials}}\" --header \"Content-Type: {{contenttype}}\" --header \"Accept: application/json\" -O /ccp_data/annotated.json" ] }, { "name": "undeploy-script", "value": [] } ] } } ``` example: [bash example ](../methods_examples/Bash%20Example-1.0.0.json)