Chilkat Online Tools

BatchDescribeMergeConflicts Swift3 Example

AWS CodeCommit

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

    // URL: https://codecommit.us-west-2.amazonaws.com/
    // Use the same region as specified above.
    success = rest.connect("codecommit.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.update("conflictDetailLevel", value: "string")
    json.update("conflictResolutionStrategy", value: "string")
    json.update("destinationCommitSpecifier", value: "string")
    json.update("filePaths[0]", value: "string")
    json.updateInt("maxConflictFiles", value: 123)
    json.updateInt("maxMergeHunks", value: 123)
    json.update("mergeOption", value: "string")
    json.update("nextToken", value: "string")
    json.update("repositoryName", value: "string")
    json.update("sourceCommitSpecifier", value: "string")

    // The JSON request body created by the above code:

    // {
    //   "conflictDetailLevel": "string",
    //   "conflictResolutionStrategy": "string",
    //   "destinationCommitSpecifier": "string",
    //   "filePaths": [
    //     "string"
    //   ],
    //   "maxConflictFiles": number,
    //   "maxMergeHunks": number,
    //   "mergeOption": "string",
    //   "nextToken": "string",
    //   "repositoryName": "string",
    //   "sourceCommitSpecifier": "string"
    // }

    rest.addHeader("Content-Type", value: "application/x-amz-json-1.1")
    rest.addHeader("X-Amz-Target", value: "CodeCommit_20150413.BatchDescribeMergeConflicts")

    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 ContentConflict: Int
    var FileModeConflict: Int
    var Base: String?
    var Destination: String?
    var Source: String?
    var FilePath: String?
    var FileSizesBase: Int
    var FileSizesDestination: Int
    var FileSizesSource: Int
    var IsBinaryFileBase: Int
    var IsBinaryFileDestination: Int
    var IsBinaryFileSource: Int
    var MergeOperationsDestination: String?
    var MergeOperationsSource: String?
    var NumberOfConflicts: Int
    var ObjectTypeConflict: Int
    var ObjectTypesBase: String?
    var ObjectTypesDestination: String?
    var ObjectTypesSource: String?
    var j: Int
    var count_j: Int
    var EndLine: Int
    var HunkContent: String?
    var StartLine: Int
    var destinationEndLine: Int
    var destinationHunkContent: String?
    var destinationStartLine: Int
    var isConflict: Int
    var sourceEndLine: Int
    var sourceHunkContent: String?
    var sourceStartLine: Int
    var exceptionName: String?
    var filePath: String?
    var message: String?

    var baseCommitId: String? = jResp.string(of: "baseCommitId")
    var destinationCommitId: String? = jResp.string(of: "destinationCommitId")
    var nextToken: String? = jResp.string(of: "nextToken")
    var sourceCommitId: String? = jResp.string(of: "sourceCommitId")
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "conflicts").intValue
    while i < count_i {
        jResp.i = i
        ContentConflict = jResp.int(of: "conflicts[i].conflictMetadata.contentConflict").intValue
        FileModeConflict = jResp.int(of: "conflicts[i].conflictMetadata.fileModeConflict").intValue
        Base = jResp.string(of: "conflicts[i].conflictMetadata.fileModes.base")
        Destination = jResp.string(of: "conflicts[i].conflictMetadata.fileModes.destination")
        Source = jResp.string(of: "conflicts[i].conflictMetadata.fileModes.source")
        FilePath = jResp.string(of: "conflicts[i].conflictMetadata.filePath")
        FileSizesBase = jResp.int(of: "conflicts[i].conflictMetadata.fileSizes.base").intValue
        FileSizesDestination = jResp.int(of: "conflicts[i].conflictMetadata.fileSizes.destination").intValue
        FileSizesSource = jResp.int(of: "conflicts[i].conflictMetadata.fileSizes.source").intValue
        IsBinaryFileBase = jResp.int(of: "conflicts[i].conflictMetadata.isBinaryFile.base").intValue
        IsBinaryFileDestination = jResp.int(of: "conflicts[i].conflictMetadata.isBinaryFile.destination").intValue
        IsBinaryFileSource = jResp.int(of: "conflicts[i].conflictMetadata.isBinaryFile.source").intValue
        MergeOperationsDestination = jResp.string(of: "conflicts[i].conflictMetadata.mergeOperations.destination")
        MergeOperationsSource = jResp.string(of: "conflicts[i].conflictMetadata.mergeOperations.source")
        NumberOfConflicts = jResp.int(of: "conflicts[i].conflictMetadata.numberOfConflicts").intValue
        ObjectTypeConflict = jResp.int(of: "conflicts[i].conflictMetadata.objectTypeConflict").intValue
        ObjectTypesBase = jResp.string(of: "conflicts[i].conflictMetadata.objectTypes.base")
        ObjectTypesDestination = jResp.string(of: "conflicts[i].conflictMetadata.objectTypes.destination")
        ObjectTypesSource = jResp.string(of: "conflicts[i].conflictMetadata.objectTypes.source")
        j = 0
        count_j = jResp.size(ofArray: "conflicts[i].mergeHunks").intValue
        while j < count_j {
            jResp.j = j
            EndLine = jResp.int(of: "conflicts[i].mergeHunks[j].base.endLine").intValue
            HunkContent = jResp.string(of: "conflicts[i].mergeHunks[j].base.hunkContent")
            StartLine = jResp.int(of: "conflicts[i].mergeHunks[j].base.startLine").intValue
            destinationEndLine = jResp.int(of: "conflicts[i].mergeHunks[j].destination.endLine").intValue
            destinationHunkContent = jResp.string(of: "conflicts[i].mergeHunks[j].destination.hunkContent")
            destinationStartLine = jResp.int(of: "conflicts[i].mergeHunks[j].destination.startLine").intValue
            isConflict = jResp.int(of: "conflicts[i].mergeHunks[j].isConflict").intValue
            sourceEndLine = jResp.int(of: "conflicts[i].mergeHunks[j].source.endLine").intValue
            sourceHunkContent = jResp.string(of: "conflicts[i].mergeHunks[j].source.hunkContent")
            sourceStartLine = jResp.int(of: "conflicts[i].mergeHunks[j].source.startLine").intValue
            j = j + 1
        }

        i = i + 1
    }

    i = 0
    count_i = jResp.size(ofArray: "errors").intValue
    while i < count_i {
        jResp.i = i
        exceptionName = jResp.string(of: "errors[i].exceptionName")
        filePath = jResp.string(of: "errors[i].filePath")
        message = jResp.string(of: "errors[i].message")
        i = i + 1
    }

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

    // {
    //   "baseCommitId": "string",
    //   "conflicts": [
    //     {
    //       "conflictMetadata": {
    //         "contentConflict": boolean,
    //         "fileModeConflict": boolean,
    //         "fileModes": {
    //           "base": "string",
    //           "destination": "string",
    //           "source": "string"
    //         },
    //         "filePath": "string",
    //         "fileSizes": {
    //           "base": number,
    //           "destination": number,
    //           "source": number
    //         },
    //         "isBinaryFile": {
    //           "base": boolean,
    //           "destination": boolean,
    //           "source": boolean
    //         },
    //         "mergeOperations": {
    //           "destination": "string",
    //           "source": "string"
    //         },
    //         "numberOfConflicts": number,
    //         "objectTypeConflict": boolean,
    //         "objectTypes": {
    //           "base": "string",
    //           "destination": "string",
    //           "source": "string"
    //         }
    //       },
    //       "mergeHunks": [
    //         {
    //           "base": {
    //             "endLine": number,
    //             "hunkContent": "string",
    //             "startLine": number
    //           },
    //           "destination": {
    //             "endLine": number,
    //             "hunkContent": "string",
    //             "startLine": number
    //           },
    //           "isConflict": boolean,
    //           "source": {
    //             "endLine": number,
    //             "hunkContent": "string",
    //             "startLine": number
    //           }
    //         }
    //       ]
    //     }
    //   ],
    //   "destinationCommitId": "string",
    //   "errors": [
    //     {
    //       "exceptionName": "string",
    //       "filePath": "string",
    //       "message": "string"
    //     }
    //   ],
    //   "nextToken": "string",
    //   "sourceCommitId": "string"
    // }

}