DescribeFargateProfile 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 = "eks"
// SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
rest.SetAuthAws(authAws)
// URL: https://eks.us-west-2.amazonaws.com/
// Use the same region as specified above.
success = rest.Connect("eks.us-west-2.amazonaws.com", port: 443, tls: true, autoReconnect: true)
if success != true {
print("ConnectFailReason: \(rest.ConnectFailReason.intValue)")
print("\(rest.LastErrorText)")
return
}
rest.AddHeader("Content-Type", value: "application/x-amz-json-1.1")
rest.AddHeader("X-Amz-Target", value: "DescribeFargateProfile")
let sbResponseBody = CkoStringBuilder()
success = rest.FullRequestNoBodySb("GET", uriPath: "/clusters/{name}/fargate-profiles/{fargateProfileName}", sb: 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 labelsString: String?
var namespace: String?
var strVal: String?
var ClusterName: String? = jResp.StringOf("fargateProfile.clusterName")
var CreatedAt: Int = jResp.IntOf("fargateProfile.createdAt").intValue
var FargateProfileArn: String? = jResp.StringOf("fargateProfile.fargateProfileArn")
var FargateProfileName: String? = jResp.StringOf("fargateProfile.fargateProfileName")
var PodExecutionRoleArn: String? = jResp.StringOf("fargateProfile.podExecutionRoleArn")
var Status: String? = jResp.StringOf("fargateProfile.status")
var v_String: String? = jResp.StringOf("fargateProfile.tags.string")
var i: Int = 0
var count_i: Int = jResp.SizeOfArray("fargateProfile.selectors").intValue
while i < count_i {
jResp.I = i
labelsString = jResp.StringOf("fargateProfile.selectors[i].labels.string")
namespace = jResp.StringOf("fargateProfile.selectors[i].namespace")
i = i + 1
}
i = 0
count_i = jResp.SizeOfArray("fargateProfile.subnets").intValue
while i < count_i {
jResp.I = i
strVal = jResp.StringOf("fargateProfile.subnets[i]")
i = i + 1
}
// A sample JSON response body parsed by the above code:
// {
// "fargateProfile": {
// "clusterName": "string",
// "createdAt": number,
// "fargateProfileArn": "string",
// "fargateProfileName": "string",
// "podExecutionRoleArn": "string",
// "selectors": [
// {
// "labels": {
// "string": "string"
// },
// "namespace": "string"
// }
// ],
// "status": "string",
// "subnets": [
// "string"
// ],
// "tags": {
// "string": "string"
// }
// }
// }
}