Chilkat Online Tools

RegisterJobDefinition Classic ASP Example

AWS Batch

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' This example requires the Chilkat API to have been previously unlocked.
' See Global Unlock Sample for sample code.

set rest = Server.CreateObject("Chilkat_9_5_0.Rest")

set authAws = Server.CreateObject("Chilkat_9_5_0.AuthAws")
authAws.AccessKey = "AWS_ACCESS_KEY"
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.)
authAws.Region = "us-west-2"
authAws.ServiceName = "batch"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)

' URL: https://batch.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("batch.us-west-2.amazonaws.com",443,1,1)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( "ConnectFailReason: " & rest.ConnectFailReason) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
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

set json = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = json.UpdateString("containerProperties.command[0]","string")
success = json.UpdateString("containerProperties.environment[0].name","string")
success = json.UpdateString("containerProperties.environment[0].value","string")
success = json.UpdateString("containerProperties.executionRoleArn","string")
success = json.UpdateString("containerProperties.fargatePlatformConfiguration.platformVersion","string")
success = json.UpdateString("containerProperties.image","string")
success = json.UpdateString("containerProperties.instanceType","string")
success = json.UpdateString("containerProperties.jobRoleArn","string")
success = json.UpdateString("containerProperties.linuxParameters.devices[0].containerPath","string")
success = json.UpdateString("containerProperties.linuxParameters.devices[0].hostPath","string")
success = json.UpdateString("containerProperties.linuxParameters.devices[0].permissions[0]","string")
success = json.UpdateInt("containerProperties.linuxParameters.initProcessEnabled",123)
success = json.UpdateInt("containerProperties.linuxParameters.maxSwap",123)
success = json.UpdateInt("containerProperties.linuxParameters.sharedMemorySize",123)
success = json.UpdateInt("containerProperties.linuxParameters.swappiness",123)
success = json.UpdateString("containerProperties.linuxParameters.tmpfs[0].containerPath","string")
success = json.UpdateString("containerProperties.linuxParameters.tmpfs[0].mountOptions[0]","string")
success = json.UpdateInt("containerProperties.linuxParameters.tmpfs[0].size",123)
success = json.UpdateString("containerProperties.logConfiguration.logDriver","string")
success = json.UpdateString("containerProperties.logConfiguration.options.string","string")
success = json.UpdateString("containerProperties.logConfiguration.secretOptions[0].name","string")
success = json.UpdateString("containerProperties.logConfiguration.secretOptions[0].valueFrom","string")
success = json.UpdateInt("containerProperties.memory",123)
success = json.UpdateString("containerProperties.mountPoints[0].containerPath","string")
success = json.UpdateInt("containerProperties.mountPoints[0].readOnly",123)
success = json.UpdateString("containerProperties.mountPoints[0].sourceVolume","string")
success = json.UpdateString("containerProperties.networkConfiguration.assignPublicIp","string")
success = json.UpdateInt("containerProperties.privileged",123)
success = json.UpdateInt("containerProperties.readonlyRootFilesystem",123)
success = json.UpdateString("containerProperties.resourceRequirements[0].type","string")
success = json.UpdateString("containerProperties.resourceRequirements[0].value","string")
success = json.UpdateString("containerProperties.secrets[0].name","string")
success = json.UpdateString("containerProperties.secrets[0].valueFrom","string")
success = json.UpdateInt("containerProperties.ulimits[0].hardLimit",123)
success = json.UpdateString("containerProperties.ulimits[0].name","string")
success = json.UpdateInt("containerProperties.ulimits[0].softLimit",123)
success = json.UpdateString("containerProperties.user","string")
success = json.UpdateInt("containerProperties.vcpus",123)
success = json.UpdateString("containerProperties.volumes[0].efsVolumeConfiguration.authorizationConfig.accessPointId","string")
success = json.UpdateString("containerProperties.volumes[0].efsVolumeConfiguration.authorizationConfig.iam","string")
success = json.UpdateString("containerProperties.volumes[0].efsVolumeConfiguration.fileSystemId","string")
success = json.UpdateString("containerProperties.volumes[0].efsVolumeConfiguration.rootDirectory","string")
success = json.UpdateString("containerProperties.volumes[0].efsVolumeConfiguration.transitEncryption","string")
success = json.UpdateInt("containerProperties.volumes[0].efsVolumeConfiguration.transitEncryptionPort",123)
success = json.UpdateString("containerProperties.volumes[0].host.sourcePath","string")
success = json.UpdateString("containerProperties.volumes[0].name","string")
success = json.UpdateString("jobDefinitionName","string")
success = json.UpdateInt("nodeProperties.mainNode",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.command[0]","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.environment[0].name","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.environment[0].value","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.executionRoleArn","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.fargatePlatformConfiguration.platformVersion","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.image","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.instanceType","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.jobRoleArn","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.linuxParameters.devices[0].containerPath","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.linuxParameters.devices[0].hostPath","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.linuxParameters.devices[0].permissions[0]","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.linuxParameters.initProcessEnabled",123)
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.linuxParameters.maxSwap",123)
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.linuxParameters.sharedMemorySize",123)
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.linuxParameters.swappiness",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.linuxParameters.tmpfs[0].containerPath","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.linuxParameters.tmpfs[0].mountOptions[0]","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.linuxParameters.tmpfs[0].size",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.logConfiguration.logDriver","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.logConfiguration.options.string","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.logConfiguration.secretOptions[0].name","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.logConfiguration.secretOptions[0].valueFrom","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.memory",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.mountPoints[0].containerPath","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.mountPoints[0].readOnly",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.mountPoints[0].sourceVolume","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.networkConfiguration.assignPublicIp","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.privileged",123)
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.readonlyRootFilesystem",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.resourceRequirements[0].type","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.resourceRequirements[0].value","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.secrets[0].name","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.secrets[0].valueFrom","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.ulimits[0].hardLimit",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.ulimits[0].name","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.ulimits[0].softLimit",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.user","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.vcpus",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.authorizationConfig.accessPointId","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.authorizationConfig.iam","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.fileSystemId","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.rootDirectory","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.transitEncryption","string")
success = json.UpdateInt("nodeProperties.nodeRangeProperties[0].container.volumes[0].efsVolumeConfiguration.transitEncryptionPort",123)
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].host.sourcePath","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].container.volumes[0].name","string")
success = json.UpdateString("nodeProperties.nodeRangeProperties[0].targetNodes","string")
success = json.UpdateInt("nodeProperties.numNodes",123)
success = json.UpdateString("parameters.string","string")
success = json.UpdateString("platformCapabilities[0]","string")
success = json.UpdateInt("propagateTags",123)
success = json.UpdateInt("retryStrategy.attempts",123)
success = json.UpdateString("retryStrategy.evaluateOnExit[0].action","string")
success = json.UpdateString("retryStrategy.evaluateOnExit[0].onExitCode","string")
success = json.UpdateString("retryStrategy.evaluateOnExit[0].onReason","string")
success = json.UpdateString("retryStrategy.evaluateOnExit[0].onStatusReason","string")
success = json.UpdateInt("schedulingPriority",123)
success = json.UpdateString("tags.string","string")
success = json.UpdateInt("timeout.attemptDurationSeconds",123)
success = json.UpdateString("type","string")

' The JSON request body created by the above code:

' {
'   "containerProperties": {
'     "command": [
'       "string"
'     ],
'     "environment": [
'       {
'         "name": "string",
'         "value": "string"
'       }
'     ],
'     "executionRoleArn": "string",
'     "fargatePlatformConfiguration": {
'       "platformVersion": "string"
'     },
'     "image": "string",
'     "instanceType": "string",
'     "jobRoleArn": "string",
'     "linuxParameters": {
'       "devices": [
'         {
'           "containerPath": "string",
'           "hostPath": "string",
'           "permissions": [
'             "string"
'           ]
'         }
'       ],
'       "initProcessEnabled": boolean,
'       "maxSwap": number,
'       "sharedMemorySize": number,
'       "swappiness": number,
'       "tmpfs": [
'         {
'           "containerPath": "string",
'           "mountOptions": [
'             "string"
'           ],
'           "size": number
'         }
'       ]
'     },
'     "logConfiguration": {
'       "logDriver": "string",
'       "options": {
'         "string": "string"
'       },
'       "secretOptions": [
'         {
'           "name": "string",
'           "valueFrom": "string"
'         }
'       ]
'     },
'     "memory": number,
'     "mountPoints": [
'       {
'         "containerPath": "string",
'         "readOnly": boolean,
'         "sourceVolume": "string"
'       }
'     ],
'     "networkConfiguration": {
'       "assignPublicIp": "string"
'     },
'     "privileged": boolean,
'     "readonlyRootFilesystem": boolean,
'     "resourceRequirements": [
'       {
'         "type": "string",
'         "value": "string"
'       }
'     ],
'     "secrets": [
'       {
'         "name": "string",
'         "valueFrom": "string"
'       }
'     ],
'     "ulimits": [
'       {
'         "hardLimit": number,
'         "name": "string",
'         "softLimit": number
'       }
'     ],
'     "user": "string",
'     "vcpus": number,
'     "volumes": [
'       {
'         "efsVolumeConfiguration": {
'           "authorizationConfig": {
'             "accessPointId": "string",
'             "iam": "string"
'           },
'           "fileSystemId": "string",
'           "rootDirectory": "string",
'           "transitEncryption": "string",
'           "transitEncryptionPort": number
'         },
'         "host": {
'           "sourcePath": "string"
'         },
'         "name": "string"
'       }
'     ]
'   },
'   "jobDefinitionName": "string",
'   "nodeProperties": {
'     "mainNode": number,
'     "nodeRangeProperties": [
'       {
'         "container": {
'           "command": [
'             "string"
'           ],
'           "environment": [
'             {
'               "name": "string",
'               "value": "string"
'             }
'           ],
'           "executionRoleArn": "string",
'           "fargatePlatformConfiguration": {
'             "platformVersion": "string"
'           },
'           "image": "string",
'           "instanceType": "string",
'           "jobRoleArn": "string",
'           "linuxParameters": {
'             "devices": [
'               {
'                 "containerPath": "string",
'                 "hostPath": "string",
'                 "permissions": [
'                   "string"
'                 ]
'               }
'             ],
'             "initProcessEnabled": boolean,
'             "maxSwap": number,
'             "sharedMemorySize": number,
'             "swappiness": number,
'             "tmpfs": [
'               {
'                 "containerPath": "string",
'                 "mountOptions": [
'                   "string"
'                 ],
'                 "size": number
'               }
'             ]
'           },
'           "logConfiguration": {
'             "logDriver": "string",
'             "options": {
'               "string": "string"
'             },
'             "secretOptions": [
'               {
'                 "name": "string",
'                 "valueFrom": "string"
'               }
'             ]
'           },
'           "memory": number,
'           "mountPoints": [
'             {
'               "containerPath": "string",
'               "readOnly": boolean,
'               "sourceVolume": "string"
'             }
'           ],
'           "networkConfiguration": {
'             "assignPublicIp": "string"
'           },
'           "privileged": boolean,
'           "readonlyRootFilesystem": boolean,
'           "resourceRequirements": [
'             {
'               "type": "string",
'               "value": "string"
'             }
'           ],
'           "secrets": [
'             {
'               "name": "string",
'               "valueFrom": "string"
'             }
'           ],
'           "ulimits": [
'             {
'               "hardLimit": number,
'               "name": "string",
'               "softLimit": number
'             }
'           ],
'           "user": "string",
'           "vcpus": number,
'           "volumes": [
'             {
'               "efsVolumeConfiguration": {
'                 "authorizationConfig": {
'                   "accessPointId": "string",
'                   "iam": "string"
'                 },
'                 "fileSystemId": "string",
'                 "rootDirectory": "string",
'                 "transitEncryption": "string",
'                 "transitEncryptionPort": number
'               },
'               "host": {
'                 "sourcePath": "string"
'               },
'               "name": "string"
'             }
'           ]
'         },
'         "targetNodes": "string"
'       }
'     ],
'     "numNodes": number
'   },
'   "parameters": {
'     "string": "string"
'   },
'   "platformCapabilities": [
'     "string"
'   ],
'   "propagateTags": boolean,
'   "retryStrategy": {
'     "attempts": number,
'     "evaluateOnExit": [
'       {
'         "action": "string",
'         "onExitCode": "string",
'         "onReason": "string",
'         "onStatusReason": "string"
'       }
'     ]
'   },
'   "schedulingPriority": number,
'   "tags": {
'     "string": "string"
'   },
'   "timeout": {
'     "attemptDurationSeconds": number
'   },
'   "type": "string"
' }

success = rest.AddHeader("Content-Type","application/x-amz-json-1.1")
success = rest.AddHeader("X-Amz-Target","RegisterJobDefinition")

set sbRequestBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = json.EmitSb(sbRequestBody)
set sbResponseBody = Server.CreateObject("Chilkat_9_5_0.StringBuilder")
success = rest.FullRequestSb("POST","/v1/registerjobdefinition",sbRequestBody,sbResponseBody)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( rest.LastErrorText) & "</pre>"
    Response.End
End If

respStatusCode = rest.ResponseStatusCode
Response.Write "<pre>" & Server.HTMLEncode( "response status code = " & respStatusCode) & "</pre>"
If (respStatusCode <> 200) Then
    Response.Write "<pre>" & Server.HTMLEncode( "Response Header:") & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( rest.ResponseHeader) & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( "Response Body:") & "</pre>"
    Response.Write "<pre>" & Server.HTMLEncode( sbResponseBody.GetAsString()) & "</pre>"
    Response.End
End If

set jResp = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = jResp.LoadSb(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

jobDefinitionArn = jResp.StringOf("jobDefinitionArn")
jobDefinitionName = jResp.StringOf("jobDefinitionName")
revision = jResp.IntOf("revision")

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

' {
'   "jobDefinitionArn": "string",
'   "jobDefinitionName": "string",
'   "revision": number
' }

%>
</body>
</html>