Chilkat Online Tools

DescribePipeline Swift3 Example

AWS IoT Analytics

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

    // URL: https://iotanalytics.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    success = rest.connect("iotanalytics.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: "DescribePipeline")

    let sbResponseBody = CkoStringBuilder()!
    success = rest.fullRequestNoBodySb("GET", uriPath: "/pipelines/{pipelineName}", 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 v_String: String?
    var addAttributesName: String?
    var v_Next: String?
    var ChannelName: String?
    var channelName: String?
    var channelNext: String?
    var DatastoreName: String?
    var datastoreName: String?
    var Attribute: String?
    var deviceRegistryEnrichName: String?
    var deviceRegistryEnrichNext: String?
    var RoleArn: String?
    var ThingName: String?
    var deviceShadowEnrichAttribute: String?
    var deviceShadowEnrichName: String?
    var deviceShadowEnrichNext: String?
    var deviceShadowEnrichRoleArn: String?
    var deviceShadowEnrichThingName: String?
    var Filter: String?
    var filterName: String?
    var filterNext: String?
    var BatchSize: Int
    var LambdaName: String?
    var lambdaName: String?
    var lambdaNext: String?
    var mathAttribute: String?
    var Math: String?
    var mathName: String?
    var mathNext: String?
    var removeAttributesName: String?
    var removeAttributesNext: String?
    var selectAttributesName: String?
    var selectAttributesNext: String?
    var j: Int
    var count_j: Int
    var strVal: String?
    var creationTime: Int
    var id: String?
    var status: String?

    var Arn: String? = jResp.string(of: "pipeline.arn")
    var CreationTime: Int = jResp.int(of: "pipeline.creationTime").intValue
    var LastUpdateTime: Int = jResp.int(of: "pipeline.lastUpdateTime").intValue
    var Name: String? = jResp.string(of: "pipeline.name")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "pipeline.activities").intValue
    while i < count_i {
        jResp.i = i
        v_String = jResp.string(of: "pipeline.activities[i].addAttributes.attributes.string")
        addAttributesName = jResp.string(of: "pipeline.activities[i].addAttributes.name")
        v_Next = jResp.string(of: "pipeline.activities[i].addAttributes.next")
        ChannelName = jResp.string(of: "pipeline.activities[i].channel.channelName")
        channelName = jResp.string(of: "pipeline.activities[i].channel.name")
        channelNext = jResp.string(of: "pipeline.activities[i].channel.next")
        DatastoreName = jResp.string(of: "pipeline.activities[i].datastore.datastoreName")
        datastoreName = jResp.string(of: "pipeline.activities[i].datastore.name")
        Attribute = jResp.string(of: "pipeline.activities[i].deviceRegistryEnrich.attribute")
        deviceRegistryEnrichName = jResp.string(of: "pipeline.activities[i].deviceRegistryEnrich.name")
        deviceRegistryEnrichNext = jResp.string(of: "pipeline.activities[i].deviceRegistryEnrich.next")
        RoleArn = jResp.string(of: "pipeline.activities[i].deviceRegistryEnrich.roleArn")
        ThingName = jResp.string(of: "pipeline.activities[i].deviceRegistryEnrich.thingName")
        deviceShadowEnrichAttribute = jResp.string(of: "pipeline.activities[i].deviceShadowEnrich.attribute")
        deviceShadowEnrichName = jResp.string(of: "pipeline.activities[i].deviceShadowEnrich.name")
        deviceShadowEnrichNext = jResp.string(of: "pipeline.activities[i].deviceShadowEnrich.next")
        deviceShadowEnrichRoleArn = jResp.string(of: "pipeline.activities[i].deviceShadowEnrich.roleArn")
        deviceShadowEnrichThingName = jResp.string(of: "pipeline.activities[i].deviceShadowEnrich.thingName")
        Filter = jResp.string(of: "pipeline.activities[i].filter.filter")
        filterName = jResp.string(of: "pipeline.activities[i].filter.name")
        filterNext = jResp.string(of: "pipeline.activities[i].filter.next")
        BatchSize = jResp.int(of: "pipeline.activities[i].lambda.batchSize").intValue
        LambdaName = jResp.string(of: "pipeline.activities[i].lambda.lambdaName")
        lambdaName = jResp.string(of: "pipeline.activities[i].lambda.name")
        lambdaNext = jResp.string(of: "pipeline.activities[i].lambda.next")
        mathAttribute = jResp.string(of: "pipeline.activities[i].math.attribute")
        Math = jResp.string(of: "pipeline.activities[i].math.math")
        mathName = jResp.string(of: "pipeline.activities[i].math.name")
        mathNext = jResp.string(of: "pipeline.activities[i].math.next")
        removeAttributesName = jResp.string(of: "pipeline.activities[i].removeAttributes.name")
        removeAttributesNext = jResp.string(of: "pipeline.activities[i].removeAttributes.next")
        selectAttributesName = jResp.string(of: "pipeline.activities[i].selectAttributes.name")
        selectAttributesNext = jResp.string(of: "pipeline.activities[i].selectAttributes.next")
        j = 0
        count_j = jResp.size(ofArray: "pipeline.activities[i].removeAttributes.attributes").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "pipeline.activities[i].removeAttributes.attributes[j]")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "pipeline.activities[i].selectAttributes.attributes").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "pipeline.activities[i].selectAttributes.attributes[j]")
            j = j + 1
        }

        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "pipeline.reprocessingSummaries").intValue
    while i < count_i {
        jResp.i = i
        creationTime = jResp.int(of: "pipeline.reprocessingSummaries[i].creationTime").intValue
        id = jResp.string(of: "pipeline.reprocessingSummaries[i].id")
        status = jResp.string(of: "pipeline.reprocessingSummaries[i].status")
        i = i + 1
    }

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

    // {
    //   "pipeline": {
    //     "activities": [
    //       {
    //         "addAttributes": {
    //           "attributes": {
    //             "string": "string"
    //           },
    //           "name": "string",
    //           "next": "string"
    //         },
    //         "channel": {
    //           "channelName": "string",
    //           "name": "string",
    //           "next": "string"
    //         },
    //         "datastore": {
    //           "datastoreName": "string",
    //           "name": "string"
    //         },
    //         "deviceRegistryEnrich": {
    //           "attribute": "string",
    //           "name": "string",
    //           "next": "string",
    //           "roleArn": "string",
    //           "thingName": "string"
    //         },
    //         "deviceShadowEnrich": {
    //           "attribute": "string",
    //           "name": "string",
    //           "next": "string",
    //           "roleArn": "string",
    //           "thingName": "string"
    //         },
    //         "filter": {
    //           "filter": "string",
    //           "name": "string",
    //           "next": "string"
    //         },
    //         "lambda": {
    //           "batchSize": number,
    //           "lambdaName": "string",
    //           "name": "string",
    //           "next": "string"
    //         },
    //         "math": {
    //           "attribute": "string",
    //           "math": "string",
    //           "name": "string",
    //           "next": "string"
    //         },
    //         "removeAttributes": {
    //           "attributes": [
    //             "string"
    //           ],
    //           "name": "string",
    //           "next": "string"
    //         },
    //         "selectAttributes": {
    //           "attributes": [
    //             "string"
    //           ],
    //           "name": "string",
    //           "next": "string"
    //         }
    //       }
    //     ],
    //     "arn": "string",
    //     "creationTime": number,
    //     "lastUpdateTime": number,
    //     "name": "string",
    //     "reprocessingSummaries": [
    //       {
    //         "creationTime": number,
    //         "id": "string",
    //         "status": "string"
    //       }
    //     ]
    //   }
    // }

}