GetPipeline Foxpro Example
LOCAL loRest
LOCAL lnSuccess
LOCAL loAuthAws
LOCAL loJson
LOCAL loSbRequestBody
LOCAL loSbResponseBody
LOCAL lnRespStatusCode
LOCAL loJResp
LOCAL lcName
LOCAL j
LOCAL lnCount_j
LOCAL lcCategory
LOCAL lcOwner
LOCAL lcProvider
LOCAL lcActionTypeIdVersion
LOCAL lcV_String
LOCAL lcNamespace
LOCAL lcRegion
LOCAL lcRoleArn
LOCAL lnRunOrder
LOCAL k
LOCAL lnCount_k
LOCAL lcV_type
LOCAL lnCreated
LOCAL lcPipelineArn
LOCAL lnUpdated
LOCAL lcId
LOCAL lcV_Type
LOCAL lcLocation
LOCAL lcArtifactStoreType
LOCAL lcEncryptionKeyId
LOCAL lcEncryptionKeyType
LOCAL lcStringLocation
LOCAL lcStringType
LOCAL lcName
LOCAL lcRoleArn
LOCAL lnVersion
LOCAL i
LOCAL lnCount_i
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loRest = CreateObject('Chilkat_9_5_0.Rest')
loAuthAws = CreateObject('Chilkat_9_5_0.AuthAws')
loAuthAws.AccessKey = "AWS_ACCESS_KEY"
loAuthAws.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.)
loAuthAws.Region = "us-west-2"
loAuthAws.ServiceName = "codepipeline"
* SetAuthAws causes Chilkat to automatically add the following headers: Authorization, X-Amz-Date
loRest.SetAuthAws(loAuthAws)
* URL: https://codepipeline.us-west-2.amazonaws.com/
* Use the same region as specified above.
lnSuccess = loRest.Connect("codepipeline.us-west-2.amazonaws.com",443,1,1)
IF (lnSuccess <> 1) THEN
? "ConnectFailReason: " + STR(loRest.ConnectFailReason)
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
CANCEL
ENDIF
* 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
loJson = CreateObject('Chilkat_9_5_0.JsonObject')
loJson.UpdateString("name","string")
loJson.UpdateInt("version",123)
* The JSON request body created by the above code:
* {
* "name": "string",
* "version": number
* }
loRest.AddHeader("Content-Type","application/x-amz-json-1.1")
loRest.AddHeader("X-Amz-Target","CodePipeline_20150709.GetPipeline")
loSbRequestBody = CreateObject('Chilkat_9_5_0.StringBuilder')
loJson.EmitSb(loSbRequestBody)
loSbResponseBody = CreateObject('Chilkat_9_5_0.StringBuilder')
lnSuccess = loRest.FullRequestSb("POST","/",loSbRequestBody,loSbResponseBody)
IF (lnSuccess <> 1) THEN
? loRest.LastErrorText
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
lnRespStatusCode = loRest.ResponseStatusCode
? "response status code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode <> 200) THEN
? "Response Header:"
? loRest.ResponseHeader
? "Response Body:"
? loSbResponseBody.GetAsString()
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
CANCEL
ENDIF
loJResp = CreateObject('Chilkat_9_5_0.JsonObject')
loJResp.LoadSb(loSbResponseBody)
* 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
lnCreated = loJResp.IntOf("metadata.created")
lcPipelineArn = loJResp.StringOf("metadata.pipelineArn")
lnUpdated = loJResp.IntOf("metadata.updated")
lcId = loJResp.StringOf("pipeline.artifactStore.encryptionKey.id")
lcV_Type = loJResp.StringOf("pipeline.artifactStore.encryptionKey.type")
lcLocation = loJResp.StringOf("pipeline.artifactStore.location")
lcArtifactStoreType = loJResp.StringOf("pipeline.artifactStore.type")
lcEncryptionKeyId = loJResp.StringOf("pipeline.artifactStores.string.encryptionKey.id")
lcEncryptionKeyType = loJResp.StringOf("pipeline.artifactStores.string.encryptionKey.type")
lcStringLocation = loJResp.StringOf("pipeline.artifactStores.string.location")
lcStringType = loJResp.StringOf("pipeline.artifactStores.string.type")
lcName = loJResp.StringOf("pipeline.name")
lcRoleArn = loJResp.StringOf("pipeline.roleArn")
lnVersion = loJResp.IntOf("pipeline.version")
i = 0
lnCount_i = loJResp.SizeOfArray("pipeline.stages")
DO WHILE i < lnCount_i
loJResp.I = i
lcName = loJResp.StringOf("pipeline.stages[i].name")
j = 0
lnCount_j = loJResp.SizeOfArray("pipeline.stages[i].actions")
DO WHILE j < lnCount_j
loJResp.J = j
lcCategory = loJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.category")
lcOwner = loJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.owner")
lcProvider = loJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.provider")
lcActionTypeIdVersion = loJResp.StringOf("pipeline.stages[i].actions[j].actionTypeId.version")
lcV_String = loJResp.StringOf("pipeline.stages[i].actions[j].configuration.string")
lcName = loJResp.StringOf("pipeline.stages[i].actions[j].name")
lcNamespace = loJResp.StringOf("pipeline.stages[i].actions[j].namespace")
lcRegion = loJResp.StringOf("pipeline.stages[i].actions[j].region")
lcRoleArn = loJResp.StringOf("pipeline.stages[i].actions[j].roleArn")
lnRunOrder = loJResp.IntOf("pipeline.stages[i].actions[j].runOrder")
k = 0
lnCount_k = loJResp.SizeOfArray("pipeline.stages[i].actions[j].inputArtifacts")
DO WHILE k < lnCount_k
loJResp.K = k
lcName = loJResp.StringOf("pipeline.stages[i].actions[j].inputArtifacts[k].name")
k = k + 1
ENDDO
k = 0
lnCount_k = loJResp.SizeOfArray("pipeline.stages[i].actions[j].outputArtifacts")
DO WHILE k < lnCount_k
loJResp.K = k
lcName = loJResp.StringOf("pipeline.stages[i].actions[j].outputArtifacts[k].name")
k = k + 1
ENDDO
j = j + 1
ENDDO
j = 0
lnCount_j = loJResp.SizeOfArray("pipeline.stages[i].blockers")
DO WHILE j < lnCount_j
loJResp.J = j
lcName = loJResp.StringOf("pipeline.stages[i].blockers[j].name")
lcV_type = loJResp.StringOf("pipeline.stages[i].blockers[j].type")
j = j + 1
ENDDO
i = i + 1
ENDDO
* A sample JSON response body parsed by the above code:
* {
* "metadata": {
* "created": number,
* "pipelineArn": "string",
* "updated": number
* },
* "pipeline": {
* "artifactStore": {
* "encryptionKey": {
* "id": "string",
* "type": "string"
* },
* "location": "string",
* "type": "string"
* },
* "artifactStores": {
* "string": {
* "encryptionKey": {
* "id": "string",
* "type": "string"
* },
* "location": "string",
* "type": "string"
* }
* },
* "name": "string",
* "roleArn": "string",
* "stages": [
* {
* "actions": [
* {
* "actionTypeId": {
* "category": "string",
* "owner": "string",
* "provider": "string",
* "version": "string"
* },
* "configuration": {
* "string": "string"
* },
* "inputArtifacts": [
* {
* "name": "string"
* }
* ],
* "name": "string",
* "namespace": "string",
* "outputArtifacts": [
* {
* "name": "string"
* }
* ],
* "region": "string",
* "roleArn": "string",
* "runOrder": number
* }
* ],
* "blockers": [
* {
* "name": "string",
* "type": "string"
* }
* ],
* "name": "string"
* }
* ],
* "version": number
* }
* }
RELEASE loRest
RELEASE loAuthAws
RELEASE loJson
RELEASE loSbRequestBody
RELEASE loSbResponseBody
RELEASE loJResp