|
| 1 | +<!-- |
| 2 | + ~ Copyright 2022 MONAI Consortium |
| 3 | + ~ |
| 4 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + ~ you may not use this file except in compliance with the License. |
| 6 | + ~ You may obtain a copy of the License at |
| 7 | + ~ |
| 8 | + ~ http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + ~ |
| 10 | + ~ Unless required by applicable law or agreed to in writing, software |
| 11 | + ~ distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + ~ See the License for the specific language governing permissions and |
| 14 | + ~ limitations under the License. |
| 15 | +--> |
| 16 | + |
| 17 | +# Task Manager - Argo Template API |
| 18 | + |
| 19 | +The template endpoint provides the following APIs to post a new template to Argo plugin of |
| 20 | +the Task Manager. |
| 21 | + |
| 22 | + |
| 23 | +## POST /argo/template |
| 24 | + |
| 25 | +Posts a new template to Argo and returns the resultant template. |
| 26 | + |
| 27 | +### Parameters |
| 28 | + |
| 29 | +body, json string of the wrapped template |
| 30 | + |
| 31 | +### Responses |
| 32 | + |
| 33 | +Response Content Type: JSON |
| 34 | + |
| 35 | +- the actual Argo resultant template. |
| 36 | + |
| 37 | +| Code | Description | |
| 38 | +| ---- | ------------------------------- | |
| 39 | +| 200 | template posted sucsessfully. | |
| 40 | +| 400 | bad json or template post error | |
| 41 | +| 500 | Internal service error. | |
| 42 | + |
| 43 | +### Example Request |
| 44 | + |
| 45 | +file saved locally as workflowtemplate.json |
| 46 | +```json |
| 47 | +{ |
| 48 | + "Namespace": "argo", |
| 49 | + "serverDryRun": false, |
| 50 | + "submitOptions": { |
| 51 | + "parameters": [ |
| 52 | + "name=value" |
| 53 | + ] |
| 54 | + }, |
| 55 | + "template": { |
| 56 | + "metadata": { |
| 57 | + "name": "fantastic-tiger", |
| 58 | + "namespace": "argo", |
| 59 | + "labels": { |
| 60 | + "example": "true" |
| 61 | + } |
| 62 | + }, |
| 63 | + "spec": { |
| 64 | + "workflowMetadata": { |
| 65 | + "labels": { |
| 66 | + "example": "true" |
| 67 | + } |
| 68 | + }, |
| 69 | + "entrypoint": "argosay", |
| 70 | + "arguments": { |
| 71 | + "parameters": [ |
| 72 | + { |
| 73 | + "name": "message", |
| 74 | + "value": "hello argo" |
| 75 | + } |
| 76 | + ] |
| 77 | + }, |
| 78 | + "templates": [ |
| 79 | + { |
| 80 | + "name": "argosay", |
| 81 | + "inputs": { |
| 82 | + "parameters": [ |
| 83 | + { |
| 84 | + "name": "message", |
| 85 | + "value": "{{workflow.parameters.message}}" |
| 86 | + } |
| 87 | + ] |
| 88 | + }, |
| 89 | + "container": { |
| 90 | + "name": "main", |
| 91 | + "image": "argoproj/argosay:v2", |
| 92 | + "command": [ |
| 93 | + "/argosay" |
| 94 | + ], |
| 95 | + "args": [ |
| 96 | + "echo", |
| 97 | + "{{inputs.parameters.message}}" |
| 98 | + ] |
| 99 | + } |
| 100 | + } |
| 101 | + ], |
| 102 | + "ttlStrategy": { |
| 103 | + "secondsAfterCompletion": 300 |
| 104 | + }, |
| 105 | + "podGC": { |
| 106 | + "strategy": "OnPodCompletion" |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | +``` |
| 112 | + |
| 113 | +```bash |
| 114 | +curl -d @workflowtemplate.json 'http://localhost:5000/argo/template' |
| 115 | +``` |
| 116 | + |
| 117 | +### Example Response |
| 118 | + |
| 119 | +```json |
| 120 | +{ |
| 121 | + "metadata": { |
| 122 | + "creationTimestamp": "2023-03-23T17:28:34+00:00", |
| 123 | + "generation": 1, |
| 124 | + "labels": { |
| 125 | + "example": "true", |
| 126 | + "workflows.argoproj.io/creator": "system-serviceaccount-argo-argo-argo-workflows-server" |
| 127 | + }, |
| 128 | + "managedFields": [ |
| 129 | + { |
| 130 | + "apiVersion": "argoproj.io/v1alpha1", |
| 131 | + "fieldsType": "FieldsV1", |
| 132 | + "fieldsV1": {}, |
| 133 | + "manager": "argo", |
| 134 | + "operation": "Update", |
| 135 | + "time": "2023-03-23T17:28:34+00:00" |
| 136 | + } |
| 137 | + ], |
| 138 | + "name": "fantastic-tiger", |
| 139 | + "namespace": "argo", |
| 140 | + "resourceVersion": "12030505", |
| 141 | + "uid": "e7609791-2d30-4dae-a47e-f1796846068d" |
| 142 | + }, |
| 143 | + "spec": { |
| 144 | + "arguments": { |
| 145 | + "parameters": [ |
| 146 | + { |
| 147 | + "name": "message", |
| 148 | + "value": "hello argo" |
| 149 | + } |
| 150 | + ] |
| 151 | + }, |
| 152 | + "entrypoint": "argosay", |
| 153 | + "podGC": { |
| 154 | + "strategy": "OnPodCompletion" |
| 155 | + }, |
| 156 | + "templates": [ |
| 157 | + { |
| 158 | + "container": { |
| 159 | + "args": [ |
| 160 | + "echo", |
| 161 | + "{{inputs.parameters.message}}" |
| 162 | + ], |
| 163 | + "command": [ |
| 164 | + "/argosay" |
| 165 | + ], |
| 166 | + "image": "argoproj/argosay:v2", |
| 167 | + "name": "main", |
| 168 | + "resources": {} |
| 169 | + }, |
| 170 | + "inputs": { |
| 171 | + "parameters": [ |
| 172 | + { |
| 173 | + "name": "message", |
| 174 | + "value": "{{workflow.parameters.message}}" |
| 175 | + } |
| 176 | + ] |
| 177 | + }, |
| 178 | + "metadata": {}, |
| 179 | + "name": "argosay", |
| 180 | + "outputs": {} |
| 181 | + } |
| 182 | + ], |
| 183 | + "ttlStrategy": { |
| 184 | + "secondsAfterCompletion": 300 |
| 185 | + }, |
| 186 | + "workflowMetadata": { |
| 187 | + "labels": { |
| 188 | + "example": "true" |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | +} |
| 193 | +``` |
0 commit comments