@@ -21,6 +21,7 @@ interface WorkflowDeploymentInfo {
2121 endpoint : string
2222 exampleCommand : string
2323 needsRedeployment : boolean
24+ isPublicApi ?: boolean
2425}
2526
2627interface ApiDeployProps {
@@ -107,12 +108,12 @@ export function ApiDeploy({
107108 if ( ! info ) return ''
108109 const endpoint = getBaseEndpoint ( )
109110 const payload = getPayloadObject ( )
111+ const isPublic = info . isPublicApi
110112
111113 switch ( language ) {
112114 case 'curl' :
113115 return `curl -X POST \\
114- -H "X-API-Key: $SIM_API_KEY" \\
115- -H "Content-Type: application/json" \\
116+ ${ isPublic ? '' : ' -H "X-API-Key: $SIM_API_KEY" \\\n' } -H "Content-Type: application/json" \\
116117 -d '${ JSON . stringify ( payload ) } ' \\
117118 ${ endpoint } `
118119
@@ -123,8 +124,7 @@ import requests
123124response = requests.post(
124125 "${ endpoint } ",
125126 headers={
126- "X-API-Key": os.environ.get("SIM_API_KEY"),
127- "Content-Type": "application/json"
127+ ${ isPublic ? '' : ' "X-API-Key": os.environ.get("SIM_API_KEY"),\n' } "Content-Type": "application/json"
128128 },
129129 json=${ JSON . stringify ( payload , null , 4 ) . replace ( / \n / g, '\n ' ) }
130130)
@@ -135,8 +135,7 @@ print(response.json())`
135135 return `const response = await fetch("${ endpoint } ", {
136136 method: "POST",
137137 headers: {
138- "X-API-Key": process.env.SIM_API_KEY,
139- "Content-Type": "application/json"
138+ ${ isPublic ? '' : ' "X-API-Key": process.env.SIM_API_KEY,\n' } "Content-Type": "application/json"
140139 },
141140 body: JSON.stringify(${ JSON . stringify ( payload ) } )
142141});
@@ -148,8 +147,7 @@ console.log(data);`
148147 return `const response = await fetch("${ endpoint } ", {
149148 method: "POST",
150149 headers: {
151- "X-API-Key": process.env.SIM_API_KEY,
152- "Content-Type": "application/json"
150+ ${ isPublic ? '' : ' "X-API-Key": process.env.SIM_API_KEY,\n' } "Content-Type": "application/json"
153151 },
154152 body: JSON.stringify(${ JSON . stringify ( payload ) } )
155153});
@@ -166,12 +164,12 @@ console.log(data);`
166164 if ( ! info ) return ''
167165 const endpoint = getBaseEndpoint ( )
168166 const payload = getStreamPayloadObject ( )
167+ const isPublic = info . isPublicApi
169168
170169 switch ( language ) {
171170 case 'curl' :
172171 return `curl -X POST \\
173- -H "X-API-Key: $SIM_API_KEY" \\
174- -H "Content-Type: application/json" \\
172+ ${ isPublic ? '' : ' -H "X-API-Key: $SIM_API_KEY" \\\n' } -H "Content-Type: application/json" \\
175173 -d '${ JSON . stringify ( payload ) } ' \\
176174 ${ endpoint } `
177175
@@ -182,8 +180,7 @@ import requests
182180response = requests.post(
183181 "${ endpoint } ",
184182 headers={
185- "X-API-Key": os.environ.get("SIM_API_KEY"),
186- "Content-Type": "application/json"
183+ ${ isPublic ? '' : ' "X-API-Key": os.environ.get("SIM_API_KEY"),\n' } "Content-Type": "application/json"
187184 },
188185 json=${ JSON . stringify ( payload , null , 4 ) . replace ( / \n / g, '\n ' ) } ,
189186 stream=True
@@ -197,8 +194,7 @@ for line in response.iter_lines():
197194 return `const response = await fetch("${ endpoint } ", {
198195 method: "POST",
199196 headers: {
200- "X-API-Key": process.env.SIM_API_KEY,
201- "Content-Type": "application/json"
197+ ${ isPublic ? '' : ' "X-API-Key": process.env.SIM_API_KEY,\n' } "Content-Type": "application/json"
202198 },
203199 body: JSON.stringify(${ JSON . stringify ( payload ) } )
204200});
@@ -216,8 +212,7 @@ while (true) {
216212 return `const response = await fetch("${ endpoint } ", {
217213 method: "POST",
218214 headers: {
219- "X-API-Key": process.env.SIM_API_KEY,
220- "Content-Type": "application/json"
215+ ${ isPublic ? '' : ' "X-API-Key": process.env.SIM_API_KEY,\n' } "Content-Type": "application/json"
221216 },
222217 body: JSON.stringify(${ JSON . stringify ( payload ) } )
223218});
@@ -241,14 +236,14 @@ while (true) {
241236 const endpoint = getBaseEndpoint ( )
242237 const baseUrl = endpoint . split ( '/api/workflows/' ) [ 0 ]
243238 const payload = getPayloadObject ( )
239+ const isPublic = info . isPublicApi
244240
245241 switch ( asyncExampleType ) {
246242 case 'execute' :
247243 switch ( language ) {
248244 case 'curl' :
249245 return `curl -X POST \\
250- -H "X-API-Key: $SIM_API_KEY" \\
251- -H "Content-Type: application/json" \\
246+ ${ isPublic ? '' : ' -H "X-API-Key: $SIM_API_KEY" \\\n' } -H "Content-Type: application/json" \\
252247 -H "X-Execution-Mode: async" \\
253248 -d '${ JSON . stringify ( payload ) } ' \\
254249 ${ endpoint } `
@@ -260,8 +255,7 @@ import requests
260255response = requests.post(
261256 "${ endpoint } ",
262257 headers={
263- "X-API-Key": os.environ.get("SIM_API_KEY"),
264- "Content-Type": "application/json",
258+ ${ isPublic ? '' : ' "X-API-Key": os.environ.get("SIM_API_KEY"),\n' } "Content-Type": "application/json",
265259 "X-Execution-Mode": "async"
266260 },
267261 json=${ JSON . stringify ( payload , null , 4 ) . replace ( / \n / g, '\n ' ) }
@@ -274,8 +268,7 @@ print(job) # Contains jobId and executionId`
274268 return `const response = await fetch("${ endpoint } ", {
275269 method: "POST",
276270 headers: {
277- "X-API-Key": process.env.SIM_API_KEY,
278- "Content-Type": "application/json",
271+ ${ isPublic ? '' : ' "X-API-Key": process.env.SIM_API_KEY,\n' } "Content-Type": "application/json",
279272 "X-Execution-Mode": "async"
280273 },
281274 body: JSON.stringify(${ JSON . stringify ( payload ) } )
@@ -288,8 +281,7 @@ console.log(job); // Contains jobId and executionId`
288281 return `const response = await fetch("${ endpoint } ", {
289282 method: "POST",
290283 headers: {
291- "X-API-Key": process.env.SIM_API_KEY,
292- "Content-Type": "application/json",
284+ ${ isPublic ? '' : ' "X-API-Key": process.env.SIM_API_KEY,\n' } "Content-Type": "application/json",
293285 "X-Execution-Mode": "async"
294286 },
295287 body: JSON.stringify(${ JSON . stringify ( payload ) } )
0 commit comments