Chilkat Online Tools

CreateNodegroup autoit Example

Amazon Elastic Kubernetes Service

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oRest = ObjCreate("Chilkat_9_5_0.Rest")
Local $bSuccess

$oAuthAws = ObjCreate("Chilkat_9_5_0.AuthAws")
$oAuthAws.AccessKey = "AWS_ACCESS_KEY"
$oAuthAws.SecretKey = "AWS_SECRET_KEY"

; Don't forget to change the region to your particular region. (Also make the same change in the call to Connect below.)
$oAuthAws.Region = "us-west-2"
$oAuthAws.ServiceName = "eks"
; SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
$oRest.SetAuthAws($oAuthAws)

; URL: https://eks.us-west-2.amazonaws.com/
; Use the same region as specified above.
$bSuccess = $oRest.Connect("eks.us-west-2.amazonaws.com",443,True,True)
If ($bSuccess <> True) Then
    ConsoleWrite("ConnectFailReason: " & $oRest.ConnectFailReason & @CRLF)
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

; The following code creates the JSON request body.
; The JSON created by this code is shown below.

; Use this online tool to generate code from sample JSON:
; Generate Code to Create JSON

$oJson = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJson.UpdateString("amiType","string")
$oJson.UpdateString("capacityType","string")
$oJson.UpdateString("clientRequestToken","string")
$oJson.UpdateInt("diskSize",123)
$oJson.UpdateString("instanceTypes[0]","string")
$oJson.UpdateString("labels.string","string")
$oJson.UpdateString("launchTemplate.id","string")
$oJson.UpdateString("launchTemplate.name","string")
$oJson.UpdateString("launchTemplate.version","string")
$oJson.UpdateString("nodegroupName","string")
$oJson.UpdateString("nodeRole","string")
$oJson.UpdateString("releaseVersion","string")
$oJson.UpdateString("remoteAccess.ec2SshKey","string")
$oJson.UpdateString("remoteAccess.sourceSecurityGroups[0]","string")
$oJson.UpdateInt("scalingConfig.desiredSize",123)
$oJson.UpdateInt("scalingConfig.maxSize",123)
$oJson.UpdateInt("scalingConfig.minSize",123)
$oJson.UpdateString("subnets[0]","string")
$oJson.UpdateString("tags.string","string")
$oJson.UpdateString("taints[0].effect","string")
$oJson.UpdateString("taints[0].key","string")
$oJson.UpdateString("taints[0].value","string")
$oJson.UpdateInt("updateConfig.maxUnavailable",123)
$oJson.UpdateInt("updateConfig.maxUnavailablePercentage",123)
$oJson.UpdateString("version","string")

; The JSON request body created by the above code:

; {
;   "amiType": "string",
;   "capacityType": "string",
;   "clientRequestToken": "string",
;   "diskSize": number,
;   "instanceTypes": [
;     "string"
;   ],
;   "labels": {
;     "string": "string"
;   },
;   "launchTemplate": {
;     "id": "string",
;     "name": "string",
;     "version": "string"
;   },
;   "nodegroupName": "string",
;   "nodeRole": "string",
;   "releaseVersion": "string",
;   "remoteAccess": {
;     "ec2SshKey": "string",
;     "sourceSecurityGroups": [
;       "string"
;     ]
;   },
;   "scalingConfig": {
;     "desiredSize": number,
;     "maxSize": number,
;     "minSize": number
;   },
;   "subnets": [
;     "string"
;   ],
;   "tags": {
;     "string": "string"
;   },
;   "taints": [
;     {
;       "effect": "string",
;       "key": "string",
;       "value": "string"
;     }
;   ],
;   "updateConfig": {
;     "maxUnavailable": number,
;     "maxUnavailablePercentage": number
;   },
;   "version": "string"
; }

$oRest.AddHeader("Content-Type","application/x-amz-json-1.1")
$oRest.AddHeader("X-Amz-Target","CreateNodegroup")

$oSbRequestBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$oJson.EmitSb($oSbRequestBody)
$oSbResponseBody = ObjCreate("Chilkat_9_5_0.StringBuilder")
$bSuccess = $oRest.FullRequestSb("POST","/clusters/{name}/node-groups",$oSbRequestBody,$oSbResponseBody)
If ($bSuccess <> True) Then
    ConsoleWrite($oRest.LastErrorText & @CRLF)
    Exit
EndIf

Local $iRespStatusCode = $oRest.ResponseStatusCode
ConsoleWrite("response status code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode <> 200) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oRest.ResponseHeader & @CRLF)
    ConsoleWrite("Response Body:" & @CRLF)
    ConsoleWrite($oSbResponseBody.GetAsString() & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat_9_5_0.JsonObject")
$oJResp.LoadSb($oSbResponseBody)

; The following code parses the JSON response.
; A sample JSON response is shown below the sample code.

; Use this online tool to generate parsing code from sample JSON:
; Generate Parsing Code from JSON

Local $sCode
Local $sMessage
Local $iJ
Local $iCount_j
Local $strVal
Local $sName
Local $sEffect
Local $sKey
Local $sValue

Local $sAmiType = $oJResp.StringOf("nodegroup.amiType")
Local $sCapacityType = $oJResp.StringOf("nodegroup.capacityType")
Local $sClusterName = $oJResp.StringOf("nodegroup.clusterName")
Local $iCreatedAt = $oJResp.IntOf("nodegroup.createdAt")
Local $iDiskSize = $oJResp.IntOf("nodegroup.diskSize")
Local $sV_String = $oJResp.StringOf("nodegroup.labels.string")
Local $sId = $oJResp.StringOf("nodegroup.launchTemplate.id")
Local $sName = $oJResp.StringOf("nodegroup.launchTemplate.name")
Local $sVersion = $oJResp.StringOf("nodegroup.launchTemplate.version")
Local $iModifiedAt = $oJResp.IntOf("nodegroup.modifiedAt")
Local $sNodegroupArn = $oJResp.StringOf("nodegroup.nodegroupArn")
Local $sNodegroupName = $oJResp.StringOf("nodegroup.nodegroupName")
Local $sNodeRole = $oJResp.StringOf("nodegroup.nodeRole")
Local $sReleaseVersion = $oJResp.StringOf("nodegroup.releaseVersion")
Local $sEc2SshKey = $oJResp.StringOf("nodegroup.remoteAccess.ec2SshKey")
Local $sRemoteAccessSecurityGroup = $oJResp.StringOf("nodegroup.resources.remoteAccessSecurityGroup")
Local $iDesiredSize = $oJResp.IntOf("nodegroup.scalingConfig.desiredSize")
Local $iMaxSize = $oJResp.IntOf("nodegroup.scalingConfig.maxSize")
Local $iMinSize = $oJResp.IntOf("nodegroup.scalingConfig.minSize")
Local $sStatus = $oJResp.StringOf("nodegroup.status")
Local $sTagsString = $oJResp.StringOf("nodegroup.tags.string")
Local $iMaxUnavailable = $oJResp.IntOf("nodegroup.updateConfig.maxUnavailable")
Local $iMaxUnavailablePercentage = $oJResp.IntOf("nodegroup.updateConfig.maxUnavailablePercentage")
Local $sNodegroupVersion = $oJResp.StringOf("nodegroup.version")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("nodegroup.health.issues")
While $i < $iCount_i
    $oJResp.I = $i
    $sCode = $oJResp.StringOf("nodegroup.health.issues[i].code")
    $sMessage = $oJResp.StringOf("nodegroup.health.issues[i].message")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("nodegroup.health.issues[i].resourceIds")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("nodegroup.health.issues[i].resourceIds[j]")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("nodegroup.instanceTypes")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("nodegroup.instanceTypes[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("nodegroup.remoteAccess.sourceSecurityGroups")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("nodegroup.remoteAccess.sourceSecurityGroups[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("nodegroup.resources.autoScalingGroups")
While $i < $iCount_i
    $oJResp.I = $i
    $sName = $oJResp.StringOf("nodegroup.resources.autoScalingGroups[i].name")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("nodegroup.subnets")
While $i < $iCount_i
    $oJResp.I = $i
    $strVal = $oJResp.StringOf("nodegroup.subnets[i]")
    $i = $i + 1
Wend
$i = 0
$iCount_i = $oJResp.SizeOfArray("nodegroup.taints")
While $i < $iCount_i
    $oJResp.I = $i
    $sEffect = $oJResp.StringOf("nodegroup.taints[i].effect")
    $sKey = $oJResp.StringOf("nodegroup.taints[i].key")
    $sValue = $oJResp.StringOf("nodegroup.taints[i].value")
    $i = $i + 1
Wend

; A sample JSON response body parsed by the above code:

; {
;   "nodegroup": {
;     "amiType": "string",
;     "capacityType": "string",
;     "clusterName": "string",
;     "createdAt": number,
;     "diskSize": number,
;     "health": {
;       "issues": [
;         {
;           "code": "string",
;           "message": "string",
;           "resourceIds": [
;             "string"
;           ]
;         }
;       ]
;     },
;     "instanceTypes": [
;       "string"
;     ],
;     "labels": {
;       "string": "string"
;     },
;     "launchTemplate": {
;       "id": "string",
;       "name": "string",
;       "version": "string"
;     },
;     "modifiedAt": number,
;     "nodegroupArn": "string",
;     "nodegroupName": "string",
;     "nodeRole": "string",
;     "releaseVersion": "string",
;     "remoteAccess": {
;       "ec2SshKey": "string",
;       "sourceSecurityGroups": [
;         "string"
;       ]
;     },
;     "resources": {
;       "autoScalingGroups": [
;         {
;           "name": "string"
;         }
;       ],
;       "remoteAccessSecurityGroup": "string"
;     },
;     "scalingConfig": {
;       "desiredSize": number,
;       "maxSize": number,
;       "minSize": number
;     },
;     "status": "string",
;     "subnets": [
;       "string"
;     ],
;     "tags": {
;       "string": "string"
;     },
;     "taints": [
;       {
;         "effect": "string",
;         "key": "string",
;         "value": "string"
;       }
;     ],
;     "updateConfig": {
;       "maxUnavailable": number,
;       "maxUnavailablePercentage": number
;     },
;     "version": "string"
;   }
; }