Chilkat Online Tools

Objective-C / Cognite API v1 / Update transformations

Back to Collection Items

#import <CkoHttp.h>
#import <CkoJsonObject.h>
#import <CkoHttpResponse.h>

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

CkoHttp *http = [[CkoHttp alloc] init];
BOOL success;

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

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

// {
//   "items": [
//     {
//       "update": {
//         "name": {
//           "set": "eu voluptate"
//         },
//         "destination": {
//           "set": {
//             "type": "datapoints"
//           }
//         },
//         "conflictMode": {
//           "set": "consectetur id sed sint"
//         },
//         "query": {
//           "set": "nisi "
//         },
//         "sourceOidcCredentials": {
//           "set": {
//             "clientId": "in fugiat",
//             "clientSecret": "Excepteur minim",
//             "scopes": "ullamco Ut et nostrud Duis",
//             "tokenUri": "nostrud irure enim anim",
//             "cdfProjectName": "consequat adipisicing",
//             "audience": "dolor nulla ad"
//           }
//         },
//         "destinationOidcCredentials": {
//           "setNull": true
//         },
//         "sourceApiKey": {
//           "setNull": false
//         },
//         "destinationApiKey": {
//           "setNull": true
//         },
//         "isPublic": {
//           "set": false
//         },
//         "ignoreNullFields": {
//           "set": true
//         }
//       },
//       "id": -68015575
//     },
//     {
//       "update": {
//         "name": {
//           "set": "ea fugia"
//         },
//         "destination": {
//           "set": {
//             "type": "dolor",
//             "database": "ex fugiat veniam",
//             "table": "incididunt dolor voluptate"
//           }
//         },
//         "conflictMode": {
//           "set": "in in sunt"
//         },
//         "query": {
//           "set": "a"
//         },
//         "sourceOidcCredentials": {
//           "set": {
//             "clientId": "aliqua in",
//             "clientSecret": "sit amet",
//             "scopes": "deserunt id culpa labore",
//             "tokenUri": "elit",
//             "cdfProjectName": "nostrud aliqua",
//             "audience": "in sunt mollit labore laboris"
//           }
//         },
//         "destinationOidcCredentials": {
//           "setNull": false
//         },
//         "sourceApiKey": {
//           "setNull": false
//         },
//         "destinationApiKey": {
//           "setNull": true
//         },
//         "isPublic": {
//           "set": true
//         },
//         "ignoreNullFields": {
//           "set": true
//         }
//       },
//       "externalId": "et ut amet quis deserunt"
//     }
//   ]
// }

CkoJsonObject *json = [[CkoJsonObject alloc] init];
[json UpdateString: @"items[0].update.name.set" value: @"eu voluptate"];
[json UpdateString: @"items[0].update.destination.set.type" value: @"datapoints"];
[json UpdateString: @"items[0].update.conflictMode.set" value: @"consectetur id sed sint"];
[json UpdateString: @"items[0].update.query.set" value: @"nisi "];
[json UpdateString: @"items[0].update.sourceOidcCredentials.set.clientId" value: @"in fugiat"];
[json UpdateString: @"items[0].update.sourceOidcCredentials.set.clientSecret" value: @"Excepteur minim"];
[json UpdateString: @"items[0].update.sourceOidcCredentials.set.scopes" value: @"ullamco Ut et nostrud Duis"];
[json UpdateString: @"items[0].update.sourceOidcCredentials.set.tokenUri" value: @"nostrud irure enim anim"];
[json UpdateString: @"items[0].update.sourceOidcCredentials.set.cdfProjectName" value: @"consequat adipisicing"];
[json UpdateString: @"items[0].update.sourceOidcCredentials.set.audience" value: @"dolor nulla ad"];
[json UpdateBool: @"items[0].update.destinationOidcCredentials.setNull" value: YES];
[json UpdateBool: @"items[0].update.sourceApiKey.setNull" value: NO];
[json UpdateBool: @"items[0].update.destinationApiKey.setNull" value: YES];
[json UpdateBool: @"items[0].update.isPublic.set" value: NO];
[json UpdateBool: @"items[0].update.ignoreNullFields.set" value: YES];
[json UpdateInt: @"items[0].id" value: [NSNumber numberWithInt: -68015575]];
[json UpdateString: @"items[1].update.name.set" value: @"ea fugia"];
[json UpdateString: @"items[1].update.destination.set.type" value: @"dolor"];
[json UpdateString: @"items[1].update.destination.set.database" value: @"ex fugiat veniam"];
[json UpdateString: @"items[1].update.destination.set.table" value: @"incididunt dolor voluptate"];
[json UpdateString: @"items[1].update.conflictMode.set" value: @"in in sunt"];
[json UpdateString: @"items[1].update.query.set" value: @"a"];
[json UpdateString: @"items[1].update.sourceOidcCredentials.set.clientId" value: @"aliqua in"];
[json UpdateString: @"items[1].update.sourceOidcCredentials.set.clientSecret" value: @"sit amet"];
[json UpdateString: @"items[1].update.sourceOidcCredentials.set.scopes" value: @"deserunt id culpa labore"];
[json UpdateString: @"items[1].update.sourceOidcCredentials.set.tokenUri" value: @"elit"];
[json UpdateString: @"items[1].update.sourceOidcCredentials.set.cdfProjectName" value: @"nostrud aliqua"];
[json UpdateString: @"items[1].update.sourceOidcCredentials.set.audience" value: @"in sunt mollit labore laboris"];
[json UpdateBool: @"items[1].update.destinationOidcCredentials.setNull" value: NO];
[json UpdateBool: @"items[1].update.sourceApiKey.setNull" value: NO];
[json UpdateBool: @"items[1].update.destinationApiKey.setNull" value: YES];
[json UpdateBool: @"items[1].update.isPublic.set" value: YES];
[json UpdateBool: @"items[1].update.ignoreNullFields.set" value: YES];
[json UpdateString: @"items[1].externalId" value: @"et ut amet quis deserunt"];

[http SetRequestHeader: @"content-type" value: @"application/json"];
[http SetRequestHeader: @"api-key" value: @"{{api-key}}"];

CkoHttpResponse *resp = [http PostJson3: @"https://domain.com/api/v1/projects/{{project}}/transformations/update" contentType: @"application/json" json: json];
if (http.LastMethodSuccess == NO) {
    NSLog(@"%@",http.LastErrorText);
    return;
}

NSLog(@"%d",[resp.StatusCode intValue]);
NSLog(@"%@",resp.BodyStr);

Curl Command

curl -X POST
	-H "api-key: {{api-key}}"
	-H "content-type: application/json"
	-d '{
    "items": [
        {
            "update": {
                "name": {
                    "set": "eu voluptate"
                },
                "destination": {
                    "set": {
                        "type": "datapoints"
                    }
                },
                "conflictMode": {
                    "set": "consectetur id sed sint"
                },
                "query": {
                    "set": "nisi "
                },
                "sourceOidcCredentials": {
                    "set": {
                        "clientId": "in fugiat",
                        "clientSecret": "Excepteur minim",
                        "scopes": "ullamco Ut et nostrud Duis",
                        "tokenUri": "nostrud irure enim anim",
                        "cdfProjectName": "consequat adipisicing",
                        "audience": "dolor nulla ad"
                    }
                },
                "destinationOidcCredentials": {
                    "setNull": true
                },
                "sourceApiKey": {
                    "setNull": false
                },
                "destinationApiKey": {
                    "setNull": true
                },
                "isPublic": {
                    "set": false
                },
                "ignoreNullFields": {
                    "set": true
                }
            },
            "id": -68015575
        },
        {
            "update": {
                "name": {
                    "set": "ea fugia"
                },
                "destination": {
                    "set": {
                        "type": "dolor",
                        "database": "ex fugiat veniam",
                        "table": "incididunt dolor voluptate"
                    }
                },
                "conflictMode": {
                    "set": "in in sunt"
                },
                "query": {
                    "set": "a"
                },
                "sourceOidcCredentials": {
                    "set": {
                        "clientId": "aliqua in",
                        "clientSecret": "sit amet",
                        "scopes": "deserunt id culpa labore",
                        "tokenUri": "elit",
                        "cdfProjectName": "nostrud aliqua",
                        "audience": "in sunt mollit labore laboris"
                    }
                },
                "destinationOidcCredentials": {
                    "setNull": false
                },
                "sourceApiKey": {
                    "setNull": false
                },
                "destinationApiKey": {
                    "setNull": true
                },
                "isPublic": {
                    "set": true
                },
                "ignoreNullFields": {
                    "set": true
                }
            },
            "externalId": "et ut amet quis deserunt"
        }
    ]
}'
https://domain.com/api/v1/projects/{{project}}/transformations/update

Postman Collection Item JSON

{
  "id": "updateTransformations",
  "name": "Update transformations",
  "request": {
    "url": {
      "host": "{{baseUrl}}",
      "path": [
        "api",
        "v1",
        "projects",
        "{{project}}",
        "transformations",
        "update"
      ],
      "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": "Update the attributes of transformations, maximum 1000 per request.",
    "body": {
      "mode": "raw",
      "raw": "{\n    \"items\": [\n        {\n            \"update\": {\n                \"name\": {\n                    \"set\": \"eu voluptate\"\n                },\n                \"destination\": {\n                    \"set\": {\n                        \"type\": \"datapoints\"\n                    }\n                },\n                \"conflictMode\": {\n                    \"set\": \"consectetur id sed sint\"\n                },\n                \"query\": {\n                    \"set\": \"nisi \"\n                },\n                \"sourceOidcCredentials\": {\n                    \"set\": {\n                        \"clientId\": \"in fugiat\",\n                        \"clientSecret\": \"Excepteur minim\",\n                        \"scopes\": \"ullamco Ut et nostrud Duis\",\n                        \"tokenUri\": \"nostrud irure enim anim\",\n                        \"cdfProjectName\": \"consequat adipisicing\",\n                        \"audience\": \"dolor nulla ad\"\n                    }\n                },\n                \"destinationOidcCredentials\": {\n                    \"setNull\": true\n                },\n                \"sourceApiKey\": {\n                    \"setNull\": false\n                },\n                \"destinationApiKey\": {\n                    \"setNull\": true\n                },\n                \"isPublic\": {\n                    \"set\": false\n                },\n                \"ignoreNullFields\": {\n                    \"set\": true\n                }\n            },\n            \"id\": -68015575\n        },\n        {\n            \"update\": {\n                \"name\": {\n                    \"set\": \"ea fugia\"\n                },\n                \"destination\": {\n                    \"set\": {\n                        \"type\": \"dolor\",\n                        \"database\": \"ex fugiat veniam\",\n                        \"table\": \"incididunt dolor voluptate\"\n                    }\n                },\n                \"conflictMode\": {\n                    \"set\": \"in in sunt\"\n                },\n                \"query\": {\n                    \"set\": \"a\"\n                },\n                \"sourceOidcCredentials\": {\n                    \"set\": {\n                        \"clientId\": \"aliqua in\",\n                        \"clientSecret\": \"sit amet\",\n                        \"scopes\": \"deserunt id culpa labore\",\n                        \"tokenUri\": \"elit\",\n                        \"cdfProjectName\": \"nostrud aliqua\",\n                        \"audience\": \"in sunt mollit labore laboris\"\n                    }\n                },\n                \"destinationOidcCredentials\": {\n                    \"setNull\": false\n                },\n                \"sourceApiKey\": {\n                    \"setNull\": false\n                },\n                \"destinationApiKey\": {\n                    \"setNull\": true\n                },\n                \"isPublic\": {\n                    \"set\": true\n                },\n                \"ignoreNullFields\": {\n                    \"set\": true\n                }\n            },\n            \"externalId\": \"et ut amet quis deserunt\"\n        }\n    ]\n}"
    }
  }
}