Chilkat Online Tools

CreateNodegroup PowerBuilder Example

Amazon Elastic Kubernetes Service

integer li_rc
oleobject loo_Rest
integer li_Success
oleobject loo_AuthAws
oleobject loo_Json
oleobject loo_SbRequestBody
oleobject loo_SbResponseBody
integer li_RespStatusCode
oleobject loo_JResp
string ls_Code
string ls_Message
integer j
integer li_Count_j
string ls_StrVal
string ls_Name
string ls_Effect
string ls_Key
string ls_Value
string ls_AmiType
string ls_CapacityType
string ls_ClusterName
integer li_CreatedAt
integer li_DiskSize
string ls_V_String
string ls_Id
string ls_Name
string ls_Version
integer li_ModifiedAt
string ls_NodegroupArn
string ls_NodegroupName
string ls_NodeRole
string ls_ReleaseVersion
string ls_Ec2SshKey
string ls_RemoteAccessSecurityGroup
integer li_DesiredSize
integer li_MaxSize
integer li_MinSize
string ls_Status
string ls_TagsString
integer li_MaxUnavailable
integer li_MaxUnavailablePercentage
string ls_NodegroupVersion
integer i
integer li_Count_i

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

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat_9_5_0.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_AuthAws = create oleobject
li_rc = loo_AuthAws.ConnectToNewObject("Chilkat_9_5_0.AuthAws")

loo_AuthAws.AccessKey = "AWS_ACCESS_KEY"
loo_AuthAws.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.)
loo_AuthAws.Region = "us-west-2"
loo_AuthAws.ServiceName = "eks"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loo_Rest.SetAuthAws(loo_AuthAws)

// URL: https://eks.us-west-2.amazonaws.com/
// Use the same region as specified above.
li_Success = loo_Rest.Connect("eks.us-west-2.amazonaws.com",443,1,1)
if li_Success <> 1 then
    Write-Debug "ConnectFailReason: " + string(loo_Rest.ConnectFailReason)
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    return
end if

// 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

loo_Json = create oleobject
li_rc = loo_Json.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_Json.UpdateString("amiType","string")
loo_Json.UpdateString("capacityType","string")
loo_Json.UpdateString("clientRequestToken","string")
loo_Json.UpdateInt("diskSize",123)
loo_Json.UpdateString("instanceTypes[0]","string")
loo_Json.UpdateString("labels.string","string")
loo_Json.UpdateString("launchTemplate.id","string")
loo_Json.UpdateString("launchTemplate.name","string")
loo_Json.UpdateString("launchTemplate.version","string")
loo_Json.UpdateString("nodegroupName","string")
loo_Json.UpdateString("nodeRole","string")
loo_Json.UpdateString("releaseVersion","string")
loo_Json.UpdateString("remoteAccess.ec2SshKey","string")
loo_Json.UpdateString("remoteAccess.sourceSecurityGroups[0]","string")
loo_Json.UpdateInt("scalingConfig.desiredSize",123)
loo_Json.UpdateInt("scalingConfig.maxSize",123)
loo_Json.UpdateInt("scalingConfig.minSize",123)
loo_Json.UpdateString("subnets[0]","string")
loo_Json.UpdateString("tags.string","string")
loo_Json.UpdateString("taints[0].effect","string")
loo_Json.UpdateString("taints[0].key","string")
loo_Json.UpdateString("taints[0].value","string")
loo_Json.UpdateInt("updateConfig.maxUnavailable",123)
loo_Json.UpdateInt("updateConfig.maxUnavailablePercentage",123)
loo_Json.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"
// }

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

loo_SbRequestBody = create oleobject
li_rc = loo_SbRequestBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

loo_Json.EmitSb(loo_SbRequestBody)
loo_SbResponseBody = create oleobject
li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat_9_5_0.StringBuilder")

li_Success = loo_Rest.FullRequestSb("POST","/clusters/{name}/node-groups",loo_SbRequestBody,loo_SbResponseBody)
if li_Success <> 1 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

li_RespStatusCode = loo_Rest.ResponseStatusCode
Write-Debug "response status code = " + string(li_RespStatusCode)
if li_RespStatusCode <> 200 then
    Write-Debug "Response Header:"
    Write-Debug loo_Rest.ResponseHeader
    Write-Debug "Response Body:"
    Write-Debug loo_SbResponseBody.GetAsString()
    destroy loo_Rest
    destroy loo_AuthAws
    destroy loo_Json
    destroy loo_SbRequestBody
    destroy loo_SbResponseBody
    return
end if

loo_JResp = create oleobject
li_rc = loo_JResp.ConnectToNewObject("Chilkat_9_5_0.JsonObject")

loo_JResp.LoadSb(loo_SbResponseBody)

// 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

ls_AmiType = loo_JResp.StringOf("nodegroup.amiType")
ls_CapacityType = loo_JResp.StringOf("nodegroup.capacityType")
ls_ClusterName = loo_JResp.StringOf("nodegroup.clusterName")
li_CreatedAt = loo_JResp.IntOf("nodegroup.createdAt")
li_DiskSize = loo_JResp.IntOf("nodegroup.diskSize")
ls_V_String = loo_JResp.StringOf("nodegroup.labels.string")
ls_Id = loo_JResp.StringOf("nodegroup.launchTemplate.id")
ls_Name = loo_JResp.StringOf("nodegroup.launchTemplate.name")
ls_Version = loo_JResp.StringOf("nodegroup.launchTemplate.version")
li_ModifiedAt = loo_JResp.IntOf("nodegroup.modifiedAt")
ls_NodegroupArn = loo_JResp.StringOf("nodegroup.nodegroupArn")
ls_NodegroupName = loo_JResp.StringOf("nodegroup.nodegroupName")
ls_NodeRole = loo_JResp.StringOf("nodegroup.nodeRole")
ls_ReleaseVersion = loo_JResp.StringOf("nodegroup.releaseVersion")
ls_Ec2SshKey = loo_JResp.StringOf("nodegroup.remoteAccess.ec2SshKey")
ls_RemoteAccessSecurityGroup = loo_JResp.StringOf("nodegroup.resources.remoteAccessSecurityGroup")
li_DesiredSize = loo_JResp.IntOf("nodegroup.scalingConfig.desiredSize")
li_MaxSize = loo_JResp.IntOf("nodegroup.scalingConfig.maxSize")
li_MinSize = loo_JResp.IntOf("nodegroup.scalingConfig.minSize")
ls_Status = loo_JResp.StringOf("nodegroup.status")
ls_TagsString = loo_JResp.StringOf("nodegroup.tags.string")
li_MaxUnavailable = loo_JResp.IntOf("nodegroup.updateConfig.maxUnavailable")
li_MaxUnavailablePercentage = loo_JResp.IntOf("nodegroup.updateConfig.maxUnavailablePercentage")
ls_NodegroupVersion = loo_JResp.StringOf("nodegroup.version")
i = 0
li_Count_i = loo_JResp.SizeOfArray("nodegroup.health.issues")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Code = loo_JResp.StringOf("nodegroup.health.issues[i].code")
    ls_Message = loo_JResp.StringOf("nodegroup.health.issues[i].message")
    j = 0
    li_Count_j = loo_JResp.SizeOfArray("nodegroup.health.issues[i].resourceIds")
    do while j < li_Count_j
        loo_JResp.J = j
        ls_StrVal = loo_JResp.StringOf("nodegroup.health.issues[i].resourceIds[j]")
        j = j + 1
    loop
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("nodegroup.instanceTypes")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("nodegroup.instanceTypes[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("nodegroup.remoteAccess.sourceSecurityGroups")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("nodegroup.remoteAccess.sourceSecurityGroups[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("nodegroup.resources.autoScalingGroups")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Name = loo_JResp.StringOf("nodegroup.resources.autoScalingGroups[i].name")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("nodegroup.subnets")
do while i < li_Count_i
    loo_JResp.I = i
    ls_StrVal = loo_JResp.StringOf("nodegroup.subnets[i]")
    i = i + 1
loop
i = 0
li_Count_i = loo_JResp.SizeOfArray("nodegroup.taints")
do while i < li_Count_i
    loo_JResp.I = i
    ls_Effect = loo_JResp.StringOf("nodegroup.taints[i].effect")
    ls_Key = loo_JResp.StringOf("nodegroup.taints[i].key")
    ls_Value = loo_JResp.StringOf("nodegroup.taints[i].value")
    i = i + 1
loop

// 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"
//   }
// }


destroy loo_Rest
destroy loo_AuthAws
destroy loo_Json
destroy loo_SbRequestBody
destroy loo_SbResponseBody
destroy loo_JResp