How to use CURL / PowerShell for Controller-related processes at startup

From a Linux Controller using Curl

Create a new Token via Curl

Sample Request

curl -X POST http://<vfServerAddress>/token -H "Content-Type: application/x-www-form-urlencoded" -d "client_id=<clientId>&client_secret=<clientSecret>&grant_type=client_credentials&redirect_uri=https%3A%2F%2Flocalhost%3A7443%2Fapi%2F"

Sample Response

{"access_token":"<accessToken>","custom_parameter":19923,"expires_in":7200,"token_type":"Bearer"}

Create a new Controller via Curl

Sample Request

curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer <accessToken>" -d '{ "application":"<applicationId>", "organization":"<organizationId>", "label":"TEST", "name":"<appname>", "image_id":"<instanceId>" }' http://<vfServerAddress>/api/internal/v1/organizations/controllers/create

Sample Response

{"controller":{"organization":"<organizationId>","application":"<applicationId>","data":{"latest_stat":{"report_time":"0001-01-01T00:00:00Z","cpu_percent":0,"error_count":0,"latency_avg":0,"controller_version":"","procotol_version":0,"health":null},"offloadConfig":"","label":"TEST","status":"idle","last_active":"2023-11-10T04:36:15.83880013Z","name":"<appName>","image_id":"<instanceId>","monitor_status":"up"},"uuid":"<uuid>","createDate":"2023-11-10T04:36:15.861882Z","updateDate":"2023-11-10T04:36:15.861882Z","deleteDate":null},"password":"<password>","success":true}

From a Windows Controller using PowerShell

Create a new Token using PowerShell

Sample Request

curl -Method POST -Uri http://<vfServerAddress>/token -H @{'Content-Type'='application/x-www-form-urlencoded'} -Body @{client_id='<clientId>';client_secret='<clientSecret>';grant_type='client_credentials';redirect_uri='https%3A%2F%2Flocalhost%3A7443%2Fapi%2F'}

Sample Response

StatusCode        : 200
StatusDescription : OK
Content           : {"access_token":"<accessToken>"}
RawContent        : HTTP/1.1 200 OK
                    Connection: keep-alive
                    Pragma: no-cache
                    Content-Security-Policy: default-src 'self';font-src 'self' data: fonts.gstatic.com;style-src
                    'self' 'unsafe-inline' fonts.googleapis.com;scr...
Forms             : {}
Headers           : {[Connection, keep-alive], [Pragma, no-cache], [Content-Security-Policy, default-src
                    'self';font-src 'self' data: fonts.gstatic.com;style-src 'self' 'unsafe-inline'
                    fonts.googleapis.com;script-src 'self' 'unsafe-inline' 'unsafe-eval'
                    www.googletagmanager.com;img-src 'self' data: platform.slack-edge.com;connect-src 'self'
                    s3.amazonaws.com;], [X-Frame-Options, sameorigin]...}
Images            : {}
InputFields       : {}
Links             : {}
ParsedHtml        : mshtml.HTMLDocumentClass
RawContentLength  : 442