UpdateServiceTemplateVersion Swift Example
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let rest = CkoRest()
var success: Bool
let authAws = CkoAuthAws()
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 = "proton"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws)
// URL: https://proton.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("proton.us-west-2.amazonaws.com", port: 443, tls: true, autoReconnect: true)
if success != true {
print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
print("\(rest.LastErrorText)")
return
}
// 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
let json = CkoJsonObject()
json.UpdateString("compatibleEnvironmentTemplates[0].majorVersion", value: "string")
json.UpdateString("compatibleEnvironmentTemplates[0].templateName", value: "string")
json.UpdateString("description", value: "string")
json.UpdateString("majorVersion", value: "string")
json.UpdateString("minorVersion", value: "string")
json.UpdateString("status", value: "string")
json.UpdateString("templateName", value: "string")
// The JSON request body created by the above code:
// {
// "compatibleEnvironmentTemplates": [
// {
// "majorVersion": "string",
// "templateName": "string"
// }
// ],
// "description": "string",
// "majorVersion": "string",
// "minorVersion": "string",
// "status": "string",
// "templateName": "string"
// }
rest.AddHeader("Content-Type", value: "application/x-amz-json-1.0")
rest.AddHeader("X-Amz-Target", value: "AwsProton20200720.UpdateServiceTemplateVersion")
let sbRequestBody = CkoStringBuilder()
json.EmitSb(sbRequestBody)
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestSb("POST", uriPath: "/", requestBody: sbRequestBody, responseBody: sbResponseBody)
if success != true {
print("\(rest.LastErrorText)")
return
}
var respStatusCode: Int = rest.ResponseStatusCode.intValue
print("response status code = \(respStatusCode)")
if respStatusCode != 200 {
print("Response Header:")
print("\(rest.ResponseHeader)")
print("Response Body:")
print("\(sbResponseBody.GetAsString())")
return
}
let jResp = CkoJsonObject()
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
var majorVersion: String?
var templateName: String?
var Arn: String? = jResp.StringOf("serviceTemplateVersion.arn")
var CreatedAt: Int = jResp.IntOf("serviceTemplateVersion.createdAt").intValue
var Description: String? = jResp.StringOf("serviceTemplateVersion.description")
var LastModifiedAt: Int = jResp.IntOf("serviceTemplateVersion.lastModifiedAt").intValue
var MajorVersion: String? = jResp.StringOf("serviceTemplateVersion.majorVersion")
var MinorVersion: String? = jResp.StringOf("serviceTemplateVersion.minorVersion")
var RecommendedMinorVersion: String? = jResp.StringOf("serviceTemplateVersion.recommendedMinorVersion")
var Schema: String? = jResp.StringOf("serviceTemplateVersion.schema")
var Status: String? = jResp.StringOf("serviceTemplateVersion.status")
var StatusMessage: String? = jResp.StringOf("serviceTemplateVersion.statusMessage")
var TemplateName: String? = jResp.StringOf("serviceTemplateVersion.templateName")
var i: Int = 0
var count_i: Int = jResp.SizeOfArray("serviceTemplateVersion.compatibleEnvironmentTemplates").intValue
while i < count_i {
jResp.I = i
majorVersion = jResp.StringOf("serviceTemplateVersion.compatibleEnvironmentTemplates[i].majorVersion")
templateName = jResp.StringOf("serviceTemplateVersion.compatibleEnvironmentTemplates[i].templateName")
i = i + 1
}
// A sample JSON response body parsed by the above code:
// {
// "serviceTemplateVersion": {
// "arn": "string",
// "compatibleEnvironmentTemplates": [
// {
// "majorVersion": "string",
// "templateName": "string"
// }
// ],
// "createdAt": number,
// "description": "string",
// "lastModifiedAt": number,
// "majorVersion": "string",
// "minorVersion": "string",
// "recommendedMinorVersion": "string",
// "schema": "string",
// "status": "string",
// "statusMessage": "string",
// "templateName": "string"
// }
// }
}