Chilkat Online Tools

DeleteApp VBScript Example

Amplify

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

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

set rest = CreateObject("Chilkat_9_5_0.Rest")

set authAws = 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 = "amplify"
' SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
success = rest.SetAuthAws(authAws)

' URL: https://amplify.us-west-2.amazonaws.com/
' Use the same region as specified above.
success = rest.Connect("amplify.us-west-2.amazonaws.com",443,1,1)
If (success <> 1) Then
    outFile.WriteLine("ConnectFailReason: " & rest.ConnectFailReason)
    outFile.WriteLine(rest.LastErrorText)
    WScript.Quit
End If

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

set sbResponseBody = CreateObject("Chilkat_9_5_0.StringBuilder")
success = rest.FullRequestNoBodySb("DELETE","/apps/{appId}",sbResponseBody)
If (success <> 1) Then
    outFile.WriteLine(rest.LastErrorText)
    WScript.Quit
End If

respStatusCode = rest.ResponseStatusCode
outFile.WriteLine("response status code = " & respStatusCode)
If (respStatusCode <> 200) Then
    outFile.WriteLine("Response Header:")
    outFile.WriteLine(rest.ResponseHeader)
    outFile.WriteLine("Response Body:")
    outFile.WriteLine(sbResponseBody.GetAsString())
    WScript.Quit
End If

set jResp = 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

AppArn = jResp.StringOf("app.appArn")
AppId = jResp.StringOf("app.appId")
BasicAuthCredentials = jResp.StringOf("app.autoBranchCreationConfig.basicAuthCredentials")
BuildSpec = jResp.StringOf("app.autoBranchCreationConfig.buildSpec")
EnableAutoBuild = jResp.IntOf("app.autoBranchCreationConfig.enableAutoBuild")
EnableBasicAuth = jResp.IntOf("app.autoBranchCreationConfig.enableBasicAuth")
EnablePerformanceMode = jResp.IntOf("app.autoBranchCreationConfig.enablePerformanceMode")
EnablePullRequestPreview = jResp.IntOf("app.autoBranchCreationConfig.enablePullRequestPreview")
v_String = jResp.StringOf("app.autoBranchCreationConfig.environmentVariables.string")
Framework = jResp.StringOf("app.autoBranchCreationConfig.framework")
PullRequestEnvironmentName = jResp.StringOf("app.autoBranchCreationConfig.pullRequestEnvironmentName")
Stage = jResp.StringOf("app.autoBranchCreationConfig.stage")
appBasicAuthCredentials = jResp.StringOf("app.basicAuthCredentials")
appBuildSpec = jResp.StringOf("app.buildSpec")
CreateTime = jResp.IntOf("app.createTime")
CustomHeaders = jResp.StringOf("app.customHeaders")
DefaultDomain = jResp.StringOf("app.defaultDomain")
Description = jResp.StringOf("app.description")
EnableAutoBranchCreation = jResp.IntOf("app.enableAutoBranchCreation")
appEnableBasicAuth = jResp.IntOf("app.enableBasicAuth")
EnableBranchAutoBuild = jResp.IntOf("app.enableBranchAutoBuild")
EnableBranchAutoDeletion = jResp.IntOf("app.enableBranchAutoDeletion")
EnvironmentVariablesString = jResp.StringOf("app.environmentVariables.string")
IamServiceRoleArn = jResp.StringOf("app.iamServiceRoleArn")
Name = jResp.StringOf("app.name")
Platform = jResp.StringOf("app.platform")
BranchName = jResp.StringOf("app.productionBranch.branchName")
LastDeployTime = jResp.IntOf("app.productionBranch.lastDeployTime")
Status = jResp.StringOf("app.productionBranch.status")
ThumbnailUrl = jResp.StringOf("app.productionBranch.thumbnailUrl")
Repository = jResp.StringOf("app.repository")
RepositoryCloneMethod = jResp.StringOf("app.repositoryCloneMethod")
TagsString = jResp.StringOf("app.tags.string")
UpdateTime = jResp.IntOf("app.updateTime")
i = 0
count_i = jResp.SizeOfArray("app.autoBranchCreationPatterns")
Do While i < count_i
    jResp.I = i
    strVal = jResp.StringOf("app.autoBranchCreationPatterns[i]")
    i = i + 1
Loop
i = 0
count_i = jResp.SizeOfArray("app.customRules")
Do While i < count_i
    jResp.I = i
    condition = jResp.StringOf("app.customRules[i].condition")
    source = jResp.StringOf("app.customRules[i].source")
    status = jResp.StringOf("app.customRules[i].status")
    target = jResp.StringOf("app.customRules[i].target")
    i = i + 1
Loop

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

' {
'   "app": {
'     "appArn": "string",
'     "appId": "string",
'     "autoBranchCreationConfig": {
'       "basicAuthCredentials": "string",
'       "buildSpec": "string",
'       "enableAutoBuild": boolean,
'       "enableBasicAuth": boolean,
'       "enablePerformanceMode": boolean,
'       "enablePullRequestPreview": boolean,
'       "environmentVariables": {
'         "string": "string"
'       },
'       "framework": "string",
'       "pullRequestEnvironmentName": "string",
'       "stage": "string"
'     },
'     "autoBranchCreationPatterns": [
'       "string"
'     ],
'     "basicAuthCredentials": "string",
'     "buildSpec": "string",
'     "createTime": number,
'     "customHeaders": "string",
'     "customRules": [
'       {
'         "condition": "string",
'         "source": "string",
'         "status": "string",
'         "target": "string"
'       }
'     ],
'     "defaultDomain": "string",
'     "description": "string",
'     "enableAutoBranchCreation": boolean,
'     "enableBasicAuth": boolean,
'     "enableBranchAutoBuild": boolean,
'     "enableBranchAutoDeletion": boolean,
'     "environmentVariables": {
'       "string": "string"
'     },
'     "iamServiceRoleArn": "string",
'     "name": "string",
'     "platform": "string",
'     "productionBranch": {
'       "branchName": "string",
'       "lastDeployTime": number,
'       "status": "string",
'       "thumbnailUrl": "string"
'     },
'     "repository": "string",
'     "repositoryCloneMethod": "string",
'     "tags": {
'       "string": "string"
'     },
'     "updateTime": number
'   }
' }

outFile.Close