๐ŸŒ  UiPath, Orchestraor API๋กœ Robot ์‹คํ–‰ํ•˜๊ธฐ(Cloud Server)

Web API๋กœ UiPath ์‹คํ–‰ํ•˜๊ธฐ

Posted by labft3231 on May 20, 2020

Orchestrator API๋ฅผ ์“ฐ๋Š” ์ด์œ ?

Orchestrator๋Š” Cloud ์›น ํ™˜๊ฒฝ์ด ์ž˜๊ตฌ์„ฑ๋˜์–ด ์žˆ๊ณ  App๋„ ๋”ฐ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์–ด์„œ ์‚ฌ์‹ค ํ˜„์žฌ ์‚ฌ์šฉํ•จ์— ์žˆ์–ด์„œ๋Š” ๋ถˆํŽธํ•จ์ด ์—†์Šต๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ œํ•œ์ ์ธ ๊ธฐ๋Šฅ์„ ์ฃผ๊ฑฐ๋‚˜ ๊ด€๋ฆฌ ์ธก๋ฉด์—์„œ API๋ฅผ ์‚ฌ์šฉํ•˜๋ฉด ๋” ์œ ์šฉํ•  ๊ฒƒ์ด๋ฉฐ, ๋˜ API๋ฅผ ์ด์šฉํ•˜์—ฌ ๊ฐœ๋ฐœ์„ ํ•œ๋‹ค๋ฉด ๋‹ค๋ฅธ API๋‚˜ ๋‚ด๊ฐ€ ์›ํ•˜๋Š” ๊ธฐ๋Šฅ์„ ๋น ๋ฅด๊ฒŒ ์ ์šฉํ•˜๊ณ  ํ™œ์šฉํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ์— API๋ฅผ ์ด์šฉํ•ด๋ดค์Šต๋‹ˆ๋‹ค.

๋ณธ ํฌ์ŠคํŒ…์€ ์ธ์ฆ๋ถ€ํ„ฐ Robot ์‹คํ–‰๊นŒ์ง€์˜ ๋‚ด์šฉ์ด ๋‹ด๊ฒจ์žˆ์Šต๋‹ˆ๋‹ค.

Cloud ์„œ๋ฒ„์—์„œ Orchestrator API๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ?

์›๋ž˜ On-premiss ํ˜•ํƒœ์—์„œ ๊ฐœ๋ฐœํ•ด๋ณด๊ณ  ์‹ถ์—ˆ์ง€๋งŒ ํ˜„์žฌ On-premise๊ฐ€ ๋งŒ๋ฃŒ๋˜์–ด์„œ Cloud ์„œ๋ฒ„๋กœ ์‹คํ–‰ํ•˜์˜€์Šต๋‹ˆ๋‹ค. ์ธ์ฆ๋ถ€๋ถ„ ๋นผ๊ณ  ๋‚˜๋จธ์ง€ ๋ถ€๋ถ„์ด ๊ฐ™๊ธฐ ๋•Œ๋ฌธ์— ์ธ์ฆ ๋ถ€๋ถ„๋งŒ ๋ฐ”๊ฟ”์ฃผ๋ฉด ์–ด๋””์„œ๋“  ์‚ฌ์šฉ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค.

์ˆœ์„œ

  1. POST Auth - ๊ณ„์ • ์ธ์ฆ
  2. GET Account Logical Name - ๊ณ„์ • ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ
  3. GET serviceInstanceLogicalName - ์„œ๋น„์Šค๋ช… ๊ฐ€์ ธ์˜ค๊ธฐ
  4. GET Process Key - ํ”„๋กœ์„ธ์Šค Key ๊ฐ€์ ธ์˜ค๊ธฐ
  5. POST Robot - ๋กœ๋ด‡์‹คํ–‰ํ•˜๊ธฐ

๋กœ๋ด‡์„ ์‹คํ–‰ํ•˜๊ธฐ ๊นŒ์ง€ ๊ฐ€์ ธ์™€์•ผํ•  ๋ฐ์ดํ„ฐ๊ฐ€ ๋งŽ์Šต๋‹ˆ๋‹ค. ์ธ์ฆ์˜ token์€ 24์‹œ๊ฐ„ ์œ ์ง€ ๋ฉ๋‹ˆ๋‹ค. ์‚ฌ์šฉ์ „์— ์ธ์ฆ key๋ฅผ ์ƒˆ๋กœ ๋ฐœ๊ธ‰ ๋ฐ›๋Š”๋‹ค๋ฉด ์ธ์ฆ์‹œ๊ฐ„์— ํฌ๊ฒŒ ์‹ ๊ฒฝ ์•ˆ์จ๋„ ๋ ๊ฑฐ ๊ฐ™์•„์š”. (๋ณด์•ˆ์„ ์ƒ๊ฐํ•œ๋‹ค๋ฉด ์ธ์ฆ์„œ ๋ฐœ๊ธ‰ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๊ณ  ๋ฐ”๋กœ ์ง€์šฐ๋Š”๊ฒŒ ์ œ์ผ ์ข‹์„๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ทผ๋ฐ ๋‹ค๋ฅธ์‚ฌ๋žŒ๊ณผ ๊ฐ™์ด ์‚ฌ์šฉํ•œ๋‹ค๋ฉด transaction ๋ถ€๋ถ„๋„ ์ƒ๊ฐํ•ด์ค˜์•ผ๊ฒ ๋„ค์—ฌ.)


UiPath Doc์—์„œ๋Š” Postman์„ ์‚ฌ์šฉํ•˜๋Š”๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.
(์ €๋„ API ํ…Œ์ŠคํŠธ ํ•  ๋•Œ Postman ์จ์™”๋Š”๋ฐ insomnia๋ฅผ ์“ฐ๊ณ  ๋‚˜์„œ๋Š” insomnia๋งŒ ์“ฐ๊ฒŒ ๋˜๋„ค์š”) ์•”ํŠผ API๋งŒ ๋ณด๋‚ด๋ฉด ๋˜๊ธฐ ๋•Œ๋ฌธ์— postman, curl, insomnia ์•„๋ฌด๊ฑฐ๋‚˜ ์ƒ๊ด€์—†์Šต๋‹ˆ๋‹ค.

1. Auth - ๊ณ„์ • ์ธ์ฆ (Cloud ํ™˜๊ฒฝ์—์„œ์˜ ์ธ์ฆ)

  • cloud๋Š” ์ธ์ฆ๋ถ€๋ถ„์˜ base url์ด ๋‹ค๋ฆ„
POST /oauth/token HTTP/1.1
Accept: application/json
Host: account.uipath.com/
Content-Type: apllication/json

Reqeust
{
	"grant_type":"refresh_token",
	"client_id":"",
	"refresh_token":""
}

Response
{
  "access_token": "xxxxxxxxxxxxxxxxxxxxx",
  "id_token": "xxxxxxxxxxx",
  "scope": "openid profile email offline_access",
  "expires_in": 86400,
  "token_type": "Bearer"
}

access_token๊ณผ id_token ํš๋“

2. Account Logical Name - ๊ณ„์ • ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ

  • access_token์œผ๋กœ request ์ „์†ก
GET /cloudrpa/api/getAccountsForUser HTTP/1.1
Accept: application/json
Host: platform.uipath.com/
Content-Type: apllication/json
Authorization : Bearer 


Response
{
  "userEmail": "labft3231@gmail.com",
  "accounts": [
    {
      "accountName": "xxx",
      "accountLogicalName": "xx"
    },
    {
      "accountName": "xx",
      "accountLogicalName": "xxx"
    }
  ]
}

accountLogicalName ํš๋“

3. serviceInstanceLogicalName - ์„œ๋น„์Šค ์ด๋ฆ„ ๊ฐ€์ ธ์˜ค๊ธฐ

  • accountLogicalName์œผ๋กœ request ์ „์†ก
GET /cloudrpa/api/account//getAllServiceInstances HTTP/1.1
Accept: application/json
Host: platform.uipath.com/
Content-Type: apllication/json
Authorization : Bearer 


Response
{
  [
    {
      "serviceInstanceName": "xx",
      "serviceInstanceLogicalName": "xxx",
      "serviceType": "xxx",
      "serviceUrl": "xxx",
      "serviceState": "ENABLED",
      "userRolesInService": [
        "Administrator"
      ]
    },
  ]
}

serviceInstanceLogicalName ํš๋“

4. Process Key - ํ”„๋กœ์„ธ์Šค Key ๊ฐ€์ ธ์˜ค๊ธฐ

  • Process key ๊ฐ€์ ธ์˜ค๊ธฐ

https://platform.uipath.com/

GET ///odata/Releases HTTP/1.1
Accept: application/json
Host: platform.uipath.com/
Content-Type: apllication/json
Authorization : Bearer 


Response
{
  "@odata.context": "https://platform.uipath.com/xxxx/xxxxxxx/odata/$metadata#Releases",
  "@odata.count": 9,
  "value": [
    {
      "Key": "xxxxx-xx-xx-xx-xxxxxxx",
      "ProcessKey": "xxxxxxx",
      "ProcessVersion": "1.0.3",
      "IsLatestVersion": false,
      "IsProcessDeleted": false,
      "Description": "",
      "Name": "xx_xxxxx",
      "EnvironmentId": xxxx,
      "EnvironmentName": "xxxxx-xx",
      "InputArguments": null,
      "ProcessType": "Process",
      "SupportsMultipleEntryPoints": false,
      "RequiresUserInteraction": true,
      "AutoUpdate": false,
      "_FeedId": "00000000-0000-0000-0000-000000000000",
      "JobPriority": "Normal",
      "Id": xxx,
      "Arguments": {
        "Input": null,
        "Output": null
      },
      "ProcessSettings": null
    },
    ...
    ...
}

Process Key ํš๋“

5. Robot - ๋กœ๋ด‡์‹คํ–‰ํ•˜๊ธฐ

  • Process key๋กœ ๋กœ๋ด‡ ์‹คํ–‰
GET ///odata/Jobs/UiPath.Server.Configuration.OData.StartJobs HTTP/1.1
Accept: application/json
Host: platform.uipath.com/
Content-Type: apllication/json
Authorization : Bearer 
X-UIPATH-TenantName : 
X-UIPATH-OrganizationUnitId : 

Request
{
"startInfo": {
	"ReleaseKey": ,
	"Strategy": "All",
	"RobotIds": [],
	"NoOfRobots": 0
	}
}


Response
{
  "@odata.context": "https://platform.uipath.com/xxxx/xxxx/odata/$metadata#Jobs",
  "value": [
    {
      "Key": "xxx-xx-xxx-xx-xxxxx",
      "StartTime": null,
      "EndTime": null,
      "State": "Pending",
      "JobPriority": "Normal",
      "Source": "Manual",
      "SourceType": "Manual",
      "BatchExecutionKey": "xx-xx-xxx-xx-xxxxx",
      "Info": null,
      "CreationTime": "2020-xx-xxTxx:49:37.9692211Z",
      "StartingScheduleId": null,
      "ReleaseName": "xxxx-xxxxxx",
      "Type": "Unattended",
      "InputArguments": null,
      "OutputArguments": null,
      "HostMachineName": "xx-xxxxxx",
      "HasMediaRecorded": false,
      "PersistenceId": null,
      "ResumeVersion": null,
      "StopStrategy": null,
      "RuntimeType": null,
      "RequiresUserInteraction": true,
      "ReleaseVersionId": null,
      "EntryPointPath": null,
      "Id": xxxx
    }
  ]
}

์‹คํ–‰ํ•  Key ์ž…๋ ฅํ•˜์—ฌ์„œ ์ „์†ก์‹œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค.

๊ฒฐ๋ก 

ํ˜„์žฌ ํฌ์ŠคํŒ…์—์„œ๋Š” Robot ํ”„๋กœ์„ธ์Šค ์‹คํ–‰์— ๋Œ€ํ•ด ๋‹ค๋ฃจ์—ˆ์ง€๋งŒ ๊ธฐํƒ€ orchestrator์—์„œ ์‚ฌ์šฉ๋˜๋Š” ๋‹ค๋ฅธ API๋„ ๋งŒ๋“ค์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๋” ๋‹ค์–‘ํ•œ API๋Š” ์•„๋ž˜์˜ ์ฃผ์†Œ๋ฅผ ์ฐธ๊ณ ํ•˜์‹œ๋ฉด ๋˜๊ฒ ์Šต๋‹ˆ๋‹ค.

https://docs.uipath.com/orchestrator/reference/authenticating