Chilkat Online Tools

Swift3 / Cognite API v1 / Aggregate files

Back to Collection Items

func chilkatTest() {
    // This example assumes the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    let http = CkoHttp()!
    var success: Bool

    // Use this online tool to generate code from sample JSON: Generate Code to Create JSON

    // The following JSON is sent in the request body.

    // {
    //   "filter": {
    //     "name": "irure sed",
    //     "directoryPrefix": "nostrud consequat",
    //     "mimeType": "dolor laborum in in",
    //     "metadata": {},
    //     "assetIds": [
    //       7799666741900608,
    //       6644214122015698
    //     ],
    //     "assetExternalIds": [
    //       "quis voluptate laborum veniam",
    //       "aute ut"
    //     ],
    //     "rootAssetIds": [
    //       {
    //         "id": 6254098074953880
    //       },
    //       {
    //         "id": 8976017818812302
    //       }
    //     ],
    //     "dataSetIds": [
    //       {
    //         "externalId": "aliquip pariatur culpa cillum laborum"
    //       },
    //       {
    //         "id": 7695765338479954
    //       }
    //     ],
    //     "assetSubtreeIds": [
    //       {
    //         "externalId": "Ut amet ex cillum"
    //       },
    //       {
    //         "externalId": "sint"
    //       }
    //     ],
    //     "source": "aute Ut",
    //     "createdTime": {
    //       "max": 56270544,
    //       "min": 57758894
    //     },
    //     "lastUpdatedTime": {
    //       "max": 52283870,
    //       "min": 91808195
    //     },
    //     "uploadedTime": {
    //       "max": 26896230,
    //       "min": 27790663
    //     },
    //     "sourceCreatedTime": {
    //       "max": 2593079,
    //       "min": 10226586
    //     },
    //     "sourceModifiedTime": {
    //       "max": 74076542,
    //       "min": 32817651
    //     },
    //     "externalIdPrefix": "aliqua eu adipisicing",
    //     "uploaded": false,
    //     "labels": {
    //       "containsAny": [
    //         {
    //           "externalId": "ad aute cupidatat mollit"
    //         },
    //         {
    //           "externalId": "ex Duis sit"
    //         }
    //       ]
    //     },
    //     "geoLocation": {
    //       "relation": "INTERSECTS",
    //       "shape": {
    //         "type": "Polygon",
    //         "coordinates": [
    //         ]
    //       }
    //     }
    //   }
    // }

    let json = CkoJsonObject()!
    json.update("filter.name", value: "irure sed")
    json.update("filter.directoryPrefix", value: "nostrud consequat")
    json.update("filter.mimeType", value: "dolor laborum in in")
    json.updateNewObject("filter.metadata")
    json.updateInt("filter.assetIds[0]", value: 7799666741900608)
    json.updateInt("filter.assetIds[1]", value: 6644214122015698)
    json.update("filter.assetExternalIds[0]", value: "quis voluptate laborum veniam")
    json.update("filter.assetExternalIds[1]", value: "aute ut")
    json.updateInt("filter.rootAssetIds[0].id", value: 123)
    json.updateInt("filter.rootAssetIds[1].id", value: 123)
    json.update("filter.dataSetIds[0].externalId", value: "aliquip pariatur culpa cillum laborum")
    json.updateInt("filter.dataSetIds[1].id", value: 123)
    json.update("filter.assetSubtreeIds[0].externalId", value: "Ut amet ex cillum")
    json.update("filter.assetSubtreeIds[1].externalId", value: "sint")
    json.update("filter.source", value: "aute Ut")
    json.updateInt("filter.createdTime.max", value: 56270544)
    json.updateInt("filter.createdTime.min", value: 57758894)
    json.updateInt("filter.lastUpdatedTime.max", value: 52283870)
    json.updateInt("filter.lastUpdatedTime.min", value: 91808195)
    json.updateInt("filter.uploadedTime.max", value: 26896230)
    json.updateInt("filter.uploadedTime.min", value: 27790663)
    json.updateInt("filter.sourceCreatedTime.max", value: 2593079)
    json.updateInt("filter.sourceCreatedTime.min", value: 10226586)
    json.updateInt("filter.sourceModifiedTime.max", value: 74076542)
    json.updateInt("filter.sourceModifiedTime.min", value: 32817651)
    json.update("filter.externalIdPrefix", value: "aliqua eu adipisicing")
    json.updateBool("filter.uploaded", value: false)
    json.update("filter.labels.containsAny[0].externalId", value: "ad aute cupidatat mollit")
    json.update("filter.labels.containsAny[1].externalId", value: "ex Duis sit")
    json.update("filter.geoLocation.relation", value: "INTERSECTS")
    json.update("filter.geoLocation.shape.type", value: "Polygon")
    json.updateNewArray("filter.geoLocation.shape.coordinates")

    http.setRequestHeader("content-type", value: "application/json")
    http.setRequestHeader("api-key", value: "{{api-key}}")

    var resp: CkoHttpResponse? = http.postJson3("https://domain.com/api/v1/projects/{{project}}/files/aggregate", contentType: "application/json", json: json)
    if http.lastMethodSuccess == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("\(resp!.statusCode.intValue)")
    print("\(resp!.bodyStr!)")
    resp = nil

}

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "filter": {
        "name": "irure sed",
        "directoryPrefix": "nostrud consequat",
        "mimeType": "dolor laborum in in",
        "metadata": {},
        "assetIds": [
            7799666741900608,
            6644214122015698
        ],
        "assetExternalIds": [
            "quis voluptate laborum veniam",
            "aute ut"
        ],
        "rootAssetIds": [
            {
                "id": 6254098074953880
            },
            {
                "id": 8976017818812302
            }
        ],
        "dataSetIds": [
            {
                "externalId": "aliquip pariatur culpa cillum laborum"
            },
            {
                "id": 7695765338479954
            }
        ],
        "assetSubtreeIds": [
            {
                "externalId": "Ut amet ex cillum"
            },
            {
                "externalId": "sint"
            }
        ],
        "source": "aute Ut",
        "createdTime": {
            "max": 56270544,
            "min": 57758894
        },
        "lastUpdatedTime": {
            "max": 52283870,
            "min": 91808195
        },
        "uploadedTime": {
            "max": 26896230,
            "min": 27790663
        },
        "sourceCreatedTime": {
            "max": 2593079,
            "min": 10226586
        },
        "sourceModifiedTime": {
            "max": 74076542,
            "min": 32817651
        },
        "externalIdPrefix": "aliqua eu adipisicing",
        "uploaded": false,
        "labels": {
            "containsAny": [
                {
                    "externalId": "ad aute cupidatat mollit"
                },
                {
                    "externalId": "ex Duis sit"
                }
            ]
        },
        "geoLocation": {
            "relation": "INTERSECTS",
            "shape": {
                "type": "Polygon",
                "coordinates": []
            }
        }
    }
}'
https://domain.com/api/v1/projects/{{project}}/files/aggregate

Postman Collection Item JSON

{
  "id": "aggregateFiles",
  "name": "Aggregate files",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "files",
        "aggregate"
      ],
      "query": [
      ],
      "variable": [
      ]
    },
    "method": "POST",
    "header": [
      {
        "key": "api-key",
        "value": "{{api-key}}",
        "description": "An admin can create API keys in the Cognite console."
      },
      {
        "key": "content-type",
        "value": "application/json"
      }
    ],
    "description": "Calculate aggregates for files, based on optional filter specification. Returns the following aggregates: `count`",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"filter\": {\n        \"name\": \"irure sed\",\n        \"directoryPrefix\": \"nostrud consequat\",\n        \"mimeType\": \"dolor laborum in in\",\n        \"metadata\": {},\n        \"assetIds\": [\n            7799666741900608,\n            6644214122015698\n        ],\n        \"assetExternalIds\": [\n            \"quis voluptate laborum veniam\",\n            \"aute ut\"\n        ],\n        \"rootAssetIds\": [\n            {\n                \"id\": 6254098074953880\n            },\n            {\n                \"id\": 8976017818812302\n            }\n        ],\n        \"dataSetIds\": [\n            {\n                \"externalId\": \"aliquip pariatur culpa cillum laborum\"\n            },\n            {\n                \"id\": 7695765338479954\n            }\n        ],\n        \"assetSubtreeIds\": [\n            {\n                \"externalId\": \"Ut amet ex cillum\"\n            },\n            {\n                \"externalId\": \"sint\"\n            }\n        ],\n        \"source\": \"aute Ut\",\n        \"createdTime\": {\n            \"max\": 56270544,\n            \"min\": 57758894\n        },\n        \"lastUpdatedTime\": {\n            \"max\": 52283870,\n            \"min\": 91808195\n        },\n        \"uploadedTime\": {\n            \"max\": 26896230,\n            \"min\": 27790663\n        },\n        \"sourceCreatedTime\": {\n            \"max\": 2593079,\n            \"min\": 10226586\n        },\n        \"sourceModifiedTime\": {\n            \"max\": 74076542,\n            \"min\": 32817651\n        },\n        \"externalIdPrefix\": \"aliqua eu adipisicing\",\n        \"uploaded\": false,\n        \"labels\": {\n            \"containsAny\": [\n                {\n                    \"externalId\": \"ad aute cupidatat mollit\"\n                },\n                {\n                    \"externalId\": \"ex Duis sit\"\n                }\n            ]\n        },\n        \"geoLocation\": {\n            \"relation\": \"INTERSECTS\",\n            \"shape\": {\n                \"type\": \"Polygon\",\n                \"coordinates\": []\n            }\n        }\n    }\n}"
    }
  }
}