DeleteApp Ruby Example
require 'chilkat'
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
rest = Chilkat::CkRest.new()
authAws = Chilkat::CkAuthAws.new()
authAws.put_AccessKey("AWS_ACCESS_KEY")
authAws.put_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.put_Region("us-west-2")
authAws.put_ServiceName("amplify")
# SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
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,true,true)
if (success != true)
print "ConnectFailReason: " + rest.get_ConnectFailReason().to_s() + "\n";
print rest.lastErrorText() + "\n";
exit
end
rest.AddHeader("Content-Type","application/x-amz-json-1.1")
rest.AddHeader("X-Amz-Target","DeleteApp")
sbResponseBody = Chilkat::CkStringBuilder.new()
success = rest.FullRequestNoBodySb("DELETE","/apps/{appId}",sbResponseBody)
if (success != true)
print rest.lastErrorText() + "\n";
exit
end
respStatusCode = rest.get_ResponseStatusCode()
print "response status code = " + respStatusCode.to_s() + "\n";
if (respStatusCode != 200)
print "Response Header:" + "\n";
print rest.responseHeader() + "\n";
print "Response Body:" + "\n";
print sbResponseBody.getAsString() + "\n";
exit
end
jResp = Chilkat::CkJsonObject.new()
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")
while i < count_i
jResp.put_I(i)
strVal = jResp.stringOf("app.autoBranchCreationPatterns[i]")
i = i + 1
end
i = 0
count_i = jResp.SizeOfArray("app.customRules")
while i < count_i
jResp.put_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
end
# 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
# }
# }