posit-dev / publisher

MIT License
5 stars 0 forks source link

Add API to create Predeployment Records #772

Closed dotNomad closed 9 months ago

dotNomad commented 9 months ago

Part of the Deployment Rework in the UI

POST /api/deployments would create a “Pre-deployment Record” rather than publishing

mmarchetti commented 9 months ago

So far:

$ curl -s localhost:9001/api/deployments -XPOST -d '{"account":"dogfood","saveName":"new1"}'|jq
{
  "$schema": "https://cdn.posit.co/publisher/schemas/posit-publishing-record-schema-v3.json",
  "serverType": "connect",
  "serverUrl": "https://rsc.radixu.com",
  "id": "",
  "configurationName": "",
  "deployedAt": "",
  "saveName": "new1",
  "bundleId": "",
  "bundleUrl": "",
  "dashboardUrl": "",
  "directUrl": "",
  "deploymentError": null,
  "files": null,
  "configuration": null,
  "deploymentName": "new1",
  "deploymentPath": ".posit/publish/deployments/new1.toml"
}

$ curl -s localhost:9001/api/deployments -XPOST -d '{"account":"dogfood","saveName":"new2","config":"default"}' |jq
{
  "$schema": "https://cdn.posit.co/publisher/schemas/posit-publishing-record-schema-v3.json",
  "serverType": "connect",
  "serverUrl": "https://rsc.radixu.com",
  "id": "",
  "configurationName": "default",
  "deployedAt": "",
  "saveName": "new2",
  "bundleId": "",
  "bundleUrl": "",
  "dashboardUrl": "",
  "directUrl": "",
  "deploymentError": null,
  "files": null,
  "configuration": null,
  "deploymentName": "new2",
  "deploymentPath": ".posit/publish/deployments/new2.toml",
  "configurationPath": ".posit/publish/default.toml"
}

$ curl -is localhost:9001/api/deployments -XPOST -d '{"account":"dogfood","saveName":"new2","config":"default"}'
HTTP/1.1 409 Conflict
Vary: Origin
Date: Wed, 10 Jan 2024 16:59:43 GMT
Content-Length: 0

$ curl -is localhost:9001/api/deployments -XPOST -d '{"account":"dogfood","saveName":"new2","config":"nonexistent"}'
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Vary: Origin
X-Content-Type-Options: nosniff
Date: Wed, 10 Jan 2024 16:59:54 GMT
Content-Length: 64

open .posit/publish/nonexistent.toml: no such file or directory

$ curl -is localhost:9001/api/deployments -XPOST -d '{"account":"nonexistent","saveName":"new2","config":"default"}'
HTTP/1.1 404 Not Found
Content-Type: text/plain; charset=utf-8
Vary: Origin
X-Content-Type-Options: nosniff
Date: Wed, 10 Jan 2024 17:00:06 GMT
Content-Length: 56

cannot get account named 'nonexistent': no such account

$ curl -s localhost:9001/api/deployments/new2|jq
{
  "$schema": "https://cdn.posit.co/publisher/schemas/posit-publishing-record-schema-v3.json",
  "serverType": "connect",
  "serverUrl": "https://rsc.radixu.com",
  "id": "",
  "configurationName": "default",
  "deployedAt": "",
  "saveName": "new2",
  "bundleId": "",
  "bundleUrl": "",
  "dashboardUrl": "",
  "directUrl": "",
  "deploymentError": null,
  "files": null,
  "configuration": {
    "$schema": "https://cdn.posit.co/publisher/schemas/posit-publishing-schema-v3.json",
    "type": "unknown",
    "entrypoint": "unknown",
    "validate": true
  },
  "deploymentName": "new2",
  "deploymentPath": ".posit/publish/deployments/new2.toml",
  "configurationPath": ".posit/publish/default.toml"
}