---
policy: /ce/ca/aws/apigateway/api-execution-logging
logic: /ce/ca/aws/apigateway/api-execution-logging/prod.logic.yaml
executionTime: 2025-04-24T23:44:18.869712027Z
rows:
  - id: test1
    match: true
    status:
      expected: DISAPPEARED
      actual: DISAPPEARED
    conditionIndex:
      expected: 99
      actual: 99
    conditionText:
      expected: isDisappeared(CA10__disappearanceTime__c)
      actual: isDisappeared(CA10__disappearanceTime__c)
    runtimeError: {}
  - id: test2
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: extract('CA10__protocolType__c') == 'HTTP'
      actual: extract('CA10__protocolType__c') == 'HTTP'
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)
      actual: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 300
      actual: 300
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/apigateway/api-execution-logging/policy.yaml
    md5Hash: B7FFBE831BC47D31D42C2A0A0192F55C
    content: "---\nnames:\n  full: AWS API Gateway API Execution Logging in CloudWatch\
      \ is not enabled\n  contextual: API Execution Logging in CloudWatch is not enabled\n\
      description: >\n  Ensure that CloudWatch execution logging is enabled for APIs\
      \ in API Gateway.\n  Execution logging for API Gateway allows tracking of API\
      \ requests and responses \n  in CloudWatch, providing insights into API usage\
      \ and facilitating troubleshooting.\ncategories:\n  - \"PERFORMANCE\"\n  - \"\
      RELIABILITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/api-gateway/01\"\nsimilarPolicies:\n  internal:\n\
      \    - \"dec-x-2ac6c302\""
  - path: /ce/ca/aws/apigateway/api-execution-logging/prod.logic.yaml
    md5Hash: F8B79DD06EE0EBA2617E255FB0A4CE05
    content: |
      ---
      inputType: "CA10__CaAwsApiGatewayRestApi__c"
      importExtracts:
        - file: "/types/CA10__CaAwsApiGatewayStage__c/object.extracts.yaml"
        - file: "/types/CA10__CaAwsApiGatewayRestApi__c/object.extracts.yaml"
      testData:
        - file: test-data.json
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "HTTP API does not support execution logs."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__protocolType__c"
              right:
                TEXT: "HTTP"
        - status: "INCOMPLIANT"
          currentStateMessage: "There is at least one related API Stage where CloudWatch Execution Logs are not enabled."
          remediationMessage: "Consider enabling CloudWatch Execution Logs for the API Stage."
          check:
            RELATED_LIST_HAS:
              relationshipName: "CA10__AWS_API_Gateway_Stages__r"
              status: "INCOMPLIANT"
      otherwise:
        status: "COMPLIANT"
        currentStateMessage: "API is compliant"
      relatedLists:
        - relationshipName: "CA10__AWS_API_Gateway_Stages__r"
          conditions:
            - status: "INCOMPLIANT"
              currentStateMessage: "CloudWatch Execution Logs are not enabled for this API Stage."
              remediationMessage: "Consider enabling CloudWatch Execution Logs for this API Stage."
              check:
                IS_EMPTY:
                  arg:
                    EXTRACT: "CA10__cloudWatchLogLevel__c"
            - status: "INCOMPLIANT"
              currentStateMessage: "CloudWatch Execution Logs are turned off for this API Stage."
              remediationMessage: "Consider enabling CloudWatch Execution Logs for this API Stage."
              check:
                IS_EQUAL:
                  left:
                    EXTRACT: "CA10__cloudWatchLogLevel__c"
                  right:
                    TEXT: "OFF"
          otherwise:
            status: "COMPLIANT"
            currentStateMessage: "CloudWatch Execution Logs are enabled."
  - path: /types/CA10__CaAwsApiGatewayStage__c/object.extracts.yaml
    md5Hash: BFC9531C779AD876E602BE4C7AFCAE82
    content: "---\nextracts:\n# Values: OFF | INFO | ERROR. Nullable. Can't have no\
      \ access, retrieved via apigateway:GetStages.\n  - name: CA10__cloudWatchLogLevel__c\n\
      \    value: \n      FIELD:\n        path: CA10__cloudWatchLogLevel__c\n# Values:\
      \ Yes | No. Not nullable. Can't have no access, retrieved via apigateway:GetStages.\n\
      \  - name: CA10__xrayTracingEnabled__c\n    value: \n      FIELD:\n        path:\
      \ CA10__xrayTracingEnabled__c\n# Nullable. Can't have no access, retrieved via\
      \ apigateway:GetStages.\n  - name: CA10__webAclArn__c\n    value: \n      FIELD:\n\
      \        path: CA10__webAclArn__c"
  - path: /ce/ca/aws/apigateway/api-execution-logging/test-data.json
    md5Hash: F06FEB4B3D78B3C2B7BB9C6183F63E22
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-04T19:27:53Z"
              },
              "Id": "test1",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": "2024-11-04T19:27:53Z",
              "CA10__protocolType__c": "",
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test1_1",
                      "RecordTypeId": "RecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__cloudWatchLogLevel__c": "OFF",
                      "CA10__restApi__c": "test1",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "RecordType"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "extract('CA10__protocolType__c') == 'HTTP'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-04T19:27:53Z"
              },
              "Id": "test2",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": null,
              "CA10__protocolType__c": "HTTP",
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test2_1",
                      "RecordTypeId": "RecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__cloudWatchLogLevel__c": "OFF",
                      "CA10__restApi__c": "test2",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "RecordType"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "299",
                  "conditionText": "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-04T19:27:53Z"
              },
              "Id": "test3",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": null,
              "CA10__protocolType__c": "",
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test3_1",
                      "RecordTypeId": "RecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__cloudWatchLogLevel__c": "OFF",
                      "CA10__restApi__c": "test3",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "RecordType"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "300",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-04T19:27:53Z"
              },
              "Id": "test4",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": null,
              "CA10__protocolType__c": "",
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test4_1",
                      "RecordTypeId": "RecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__cloudWatchLogLevel__c": "INFO",
                      "CA10__restApi__c": "test4",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "RecordType"
                      }
                  }
              ]
          }
      ]
  - path: /types/CA10__CaAwsApiGatewayRestApi__c/object.extracts.yaml
    md5Hash: 746F09341E8149BAD88C53E274DB1DD5
    content: "---\nextracts:\n# Values: HTTP | WEBSOCKET. Nullable. Can't have no\
      \ access, retrieved via apigateway:GetApis.\n# Null value indicates REST type\n\
      \  - name: CA10__protocolType__c\n    value: \n      FIELD:\n        path: CA10__protocolType__c\n\
      # Values: REGIONAL | EDGE | PRIVATE. Not Nullable. Can't have no access, retrieved\
      \ via apigateway:GetRestApis.\n  - name: CA10__endpointType__c\n    value: \n\
      \      FIELD:\n        path: CA10__endpointType__c"
script: |-
  CREATE TEMP FUNCTION mock_ExpectedResult()
  RETURNS ARRAY<STRUCT<
          Id STRING,
          expectedResult STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, runtimeError STRING>
      >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "Id" : "test1",
    "expectedResult" : {
      "status" : "DISAPPEARED",
      "conditionIndex" : "99",
      "conditionText" : "isDisappeared(CA10__disappearanceTime__c)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test2",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "199",
      "conditionText" : "extract('CA10__protocolType__c') == 'HTTP'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "299",
      "conditionText" : "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "300",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayRestApi__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__protocolType__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test1",
    "RecordTypeId" : "RecordType",
    "CA10__disappearanceTime__c" : new Date("2024-11-04T19:27:53Z"),
    "CA10__protocolType__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test2",
    "RecordTypeId" : "RecordType",
    "CA10__protocolType__c" : "HTTP"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test3",
    "RecordTypeId" : "RecordType",
    "CA10__protocolType__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test4",
    "RecordTypeId" : "RecordType",
    "CA10__protocolType__c" : ""
  } ];
  """;

  CREATE TEMP FUNCTION mock_RecordType()
  RETURNS ARRAY<STRUCT<
      DeveloperName STRING,
      Id STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "DeveloperName" : "restApiStage",
    "Id" : "RecordType"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayStage__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__cloudWatchLogLevel__c STRING,
      CA10__restApi__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test1_1",
    "RecordTypeId" : "RecordType",
    "CA10__cloudWatchLogLevel__c" : "OFF",
    "CA10__restApi__c" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test2_1",
    "RecordTypeId" : "RecordType",
    "CA10__cloudWatchLogLevel__c" : "OFF",
    "CA10__restApi__c" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test3_1",
    "RecordTypeId" : "RecordType",
    "CA10__cloudWatchLogLevel__c" : "OFF",
    "CA10__restApi__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-04T19:27:53Z")
    },
    "Id" : "test4_1",
    "RecordTypeId" : "RecordType",
    "CA10__cloudWatchLogLevel__c" : "INFO",
    "CA10__restApi__c" : "test4"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsApiGatewayRestApi__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__protocolType__c STRING,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__AWS_API_Gateway_Stages__r ARRAY<STRUCT<
              Id STRING,
              RecordTypeId STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__cloudWatchLogLevel__c STRING,
              CA10__restApi__c STRING,
              RecordType STRUCT<
                  DeveloperName STRING,
                  Id STRING
              >,
              result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
          >>
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var TextLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10__protocolType__c; } return this.out; };
      references1.push('Protocol Type [obj.CA10__protocolType__c]: ' + obj.CA10__protocolType__c);
      if (TextLib.equal(extract3.call(extract3), 'HTTP')) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "extract('CA10__protocolType__c') == 'HTTP'", currentStateMessage: "HTTP API does not support execution logs.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      var count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 = 0;
      if (obj.CA10__AWS_API_Gateway_Stages__r != null) {
          for (var i6 = 0; i6 < obj.CA10__AWS_API_Gateway_Stages__r.length; i6++) {
              if (obj.CA10__AWS_API_Gateway_Stages__r[i6].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 += 1;
              }
          }
      }
      // condition[2], conditionIndex:[200..299]
      references1.push('Related list [CA10__AWS_API_Gateway_Stages__r] ' + (count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT5 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)", currentStateMessage: "There is at least one related API Stage where CloudWatch Execution Logs are not enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling CloudWatch Execution Logs for the API Stage.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "API is compliant", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__AWS_API_Gateway_Stages__r(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__cloudWatchLogLevel__c STRING,
          CA10__restApi__c STRING,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >
      >,
      snapshotTime TIMESTAMP
  )
  RETURNS STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
      var TextLib = new function () {
          this.normalize = function(arg) {
              return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase();
          };
          this.isEmpty = function(arg) {
              return this.normalize(arg) == '';
          };
          this.isNotEmpty = function(arg) {
              return this.normalize(arg) != '';
          };
          this.equal = function(left, right) {
              return this.normalize(left) == this.normalize(right);
          };
          this.notEqual = function(left, right) {
              return this.normalize(left) != this.normalize(right);
          };
          this.startsWith = function(arg, substring) {
              return this.normalize(arg).startsWith(this.normalize(substring));
          };
          this.endsWith = function(arg, substring) {
              return this.normalize(arg).endsWith(this.normalize(substring));
          };
          this.contains = function(arg, substring) {
              return this.normalize(arg).includes(this.normalize(substring));
          };
      }();
      var references1 = [];
      // condition[0], conditionIndex:[0..99]
      references1.push('Deleted From AWS [CA10__disappearanceTime__c]: ' + obj.CA10__disappearanceTime__c);
      if (obj.CA10__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function extract3() { if (!this.out) { this.out = obj.CA10__cloudWatchLogLevel__c; } return this.out; };
      references1.push('CloudWatch Logging Level [obj.CA10__cloudWatchLogLevel__c]: ' + obj.CA10__cloudWatchLogLevel__c);
      if (TextLib.isEmpty(extract3.call(extract3))) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10__cloudWatchLogLevel__c').isEmpty()", currentStateMessage: "CloudWatch Execution Logs are not enabled for this API Stage.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling CloudWatch Execution Logs for this API Stage.", runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extract6() { if (!this.out) { this.out = obj.CA10__cloudWatchLogLevel__c; } return this.out; };
      if (TextLib.equal(extract6.call(extract6), 'OFF')) {
          return {status: 'INCOMPLIANT', conditionIndex: 299, conditionText: "extract('CA10__cloudWatchLogLevel__c') == 'OFF'", currentStateMessage: "CloudWatch Execution Logs are turned off for this API Stage.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling CloudWatch Execution Logs for this API Stage.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "CloudWatch Execution Logs are enabled.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;


  SELECT
    expectedResult.Id as Id,
    IF (
      IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '')
      AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1)
      AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '')
      AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''),
      "MATCH",
      "FAIL"
    ) as match,
    expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus,
    expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex,
    expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText,
    expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError
  FROM UNNEST(mock_ExpectedResult()) expectedResult
  LEFT JOIN (
      SELECT
          sObject.Id AS Id,
          sObject.RecordTypeId AS RecordTypeId,
          sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
          sObject.CA10__protocolType__c AS CA10__protocolType__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          `CA10__AWS_API_Gateway_Stages__r`.arr AS CA10__AWS_API_Gateway_Stages__r,
          process_CA10__CaAwsApiGatewayRestApi__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__protocolType__c AS CA10__protocolType__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  `CA10__AWS_API_Gateway_Stages__r`.arr AS CA10__AWS_API_Gateway_Stages__r
              ),
              sObject.context.snapshotTime
          ) as result
      FROM UNNEST(mock_CA10__CaAwsApiGatewayRestApi__c()) AS sObject
      LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
          ON sObject.RecordTypeId = `RecordType`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10__restApi__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.RecordTypeId AS RecordTypeId,
                      sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      sObject.CA10__cloudWatchLogLevel__c AS CA10__cloudWatchLogLevel__c,
                      sObject.CA10__restApi__c AS CA10__restApi__c,
                      STRUCT (
                          `RecordType`.DeveloperName AS DeveloperName,
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      process_CA10__AWS_API_Gateway_Stages__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.RecordTypeId AS RecordTypeId,
                              sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                              sObject.CA10__cloudWatchLogLevel__c AS CA10__cloudWatchLogLevel__c,
                              sObject.CA10__restApi__c AS CA10__restApi__c,
                              STRUCT (
                                  `RecordType`.DeveloperName AS DeveloperName,
                                  `RecordType`.Id AS Id
                              ) AS RecordType
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10__CaAwsApiGatewayStage__c()) AS sObject
          LEFT JOIN UNNEST(mock_RecordType()) AS `RecordType`
              ON sObject.RecordTypeId = `RecordType`.Id
          GROUP BY sObject.CA10__restApi__c
      ) AS `CA10__AWS_API_Gateway_Stages__r`
          ON sObject.Id = `CA10__AWS_API_Gateway_Stages__r`.CA10__restApi__c
  ) sObject ON sObject.Id = expectedResult.Id;
