Hi Chris,
Thanks for getting in touch. I had to test this out to figure out the sequence of calls as I didn’t know it off the top of my head. In this scenario, I create a new SSH deploy target in Chrome w/ the network tab open and watched the example requests/responses. In general, you’ll need to create a SSH key pair account or SSH username/password account first. This is the account you mentioned. Then you can add a deployment target/machine and specify the associated data. Example below.
- Create SSH username/password account
Post to /api/accounts
Request:
{
"AccountType":"UsernamePassword",
"EnvironmentIds":[],
"Name":"Ubuntu Parallels",
"Username":"parallels",
"Password": { "NewValue":"somepassword ... " },
"TenantIds":[]
}
Response:
{
"AccountType": "UsernamePassword",
"Username": "parallels",
"Password": {
"HasValue": true,
"NewValue": null
},
"Name": "Ubuntu Parallels",
"Description": null,
"EnvironmentIds": [],
"TenantIds": [],
"TenantTags": [],
"Id": "usernamepassword-ubuntu-parallels",
"LastModifiedOn": "2017-06-09T03:57:15.135+00:00",
"LastModifiedBy": "admin",
"Links": {
"Self": "/api/accounts/usernamepassword-ubuntu-parallels"
}
}
Response:
- Create new SSH deployment target
Post to /api/machines
Request:
{
"Endpoint":
{
"CommunicationStyle":"Ssh",
"Fingerprint":"...",
"Host":"192.168.178.31",
"Port":"22",
"Uri":"ssh://192.168.178.31:22/",
"AccountId":"usernamepassword-ubuntu-parallels",
"AccountType":"UsernamePassword"
},
"Status":"Unknown",
"Name":"192.168.178.31",
"MachinePolicyId":"MachinePolicies-1",
"Roles":["web"],
"EnvironmentIds":["Environments-1"],
"TenantIds":[]
}
Response:
{
"Id": "Machines-21",
"Name": "192.168.178.31",
"Thumbprint": null,
"Uri": null,
"IsDisabled": false,
"EnvironmentIds": [
"Environments-1"
],
"Roles": [
"web"
],
"MachinePolicyId": "MachinePolicies-1",
"TenantIds": [],
"TenantTags": [],
"Status": "Unknown",
"HealthStatus": "Unknown",
"HasLatestCalamari": false,
"StatusSummary": "This machine was recently added. Please perform a health check.",
"IsInProcess": false,
"Endpoint": {
"CommunicationStyle": "Ssh",
"AccountId": "usernamepassword-ubuntu-parallels",
"Host": "192.168.178.31",
"Port": 22,
"Fingerprint": "...",
"Uri": "ssh://192.168.178.31:22/",
"ProxyId": null,
"Id": null,
"LastModifiedOn": null,
"LastModifiedBy": null,
"Links": {}
},
"LastModifiedOn": "2017-06-09T04:13:03.696+00:00",
"LastModifiedBy": "admin",
"Links": {
"Self": "/api/machines/Machines-21",
"Connection": "/api/machines/Machines-21/connection",
"TasksTemplate": "/api/machines/Machines-21/tasks{?skip}"
}
}
Note: I tested this on Octopus 3.14.0 but this should be pretty similar in older versions. I generally explore the Octopus API with Google Chrome and our API documentation wiki.
Hope this helps!
Thanks
Rob