---
policy: /ce/ca/aws/apigateway/api-access-logging
logic: /ce/ca/aws/apigateway/api-access-logging/prod.logic.yaml
executionTime: 2025-04-24T23:44:18.028264545Z
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: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)
      actual: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    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: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 199
      actual: 199
    conditionText:
      expected: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)
      actual: CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 200
      actual: 200
    conditionText:
      expected: otherwise
      actual: otherwise
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/apigateway/api-access-logging/policy.yaml
    md5Hash: 27EB0EAEDBCF4B965C9DEB6AB46A20B3
    content: "---\nnames:\n  full: AWS API Gateway API Access Logging in CloudWatch\
      \ is not enabled\n  contextual: API Access Logging in CloudWatch is not enabled\n\
      description: >\n  Ensure that access logging is enabled on API Gateway APIs,\
      \ capturing essential \n  details about API usage and access in Amazon CloudWatch\
      \ Logs. This enables \n  monitoring, troubleshooting, and auditing of API calls.\n\
      categories:\n  - \"SECURITY\"\ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n\
      \  - \"/frameworks/cloudaware/logging-and-monitoring/logging-and-monitoring-configuration\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/api-gateway/09\"\nsimilarPolicies:\n  internal:\n\
      \    - \"dec-x-d75f6d86\""
  - path: /ce/ca/aws/apigateway/api-access-logging/prod.logic.yaml
    md5Hash: A85D538DFDC61E4941F09CA061EC263A
    content: |
      ---
      inputType: "CA10__CaAwsApiGatewayRestApi__c"
      testData:
        - file: test-data.json
      conditions:
        - status: "INCOMPLIANT"
          currentStateMessage: "There is at least one related API Stage where CloudWatch Access Logs are not enabled."
          remediationMessage: "Consider enabling CloudWatch Access 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 Access Logs are not enabled for this API Stage."
              remediationMessage: "Consider enabling CloudWatch Access Logs for this API Stage."
              check:
                IS_EMPTY_LOOKUP: "CA10__accessLoggingDestination__r"
          otherwise:
            status: "COMPLIANT"
            currentStateMessage: "CloudWatch Access Logs are enabled."
  - path: /ce/ca/aws/apigateway/api-access-logging/test-data.json
    md5Hash: 80C72546B58BBFE5F161E6CFC7DED26B
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-05T19:15:56Z"
              },
              "Id": "test1",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": "2024-11-05T19:15:56Z",
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test1_1",
                      "RecordTypeId": "RecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__accessLoggingDestination__c": "",
                      "CA10__accessLoggingDestinationArn__c": "",
                      "CA10__restApi__c": "test1",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "RecordType"
                      },
                      "CA10__accessLoggingDestination__r": {
                          "Id": null,
                          "CA10__disappearanceTime__c": null
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-05T19:15:56Z"
              },
              "Id": "test2",
              "RecordTypeId": "restApiRecordType",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "restApiRecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test2_1",
                      "RecordTypeId": "restApiStageRecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__accessLoggingDestination__c": "",
                      "CA10__accessLoggingDestinationArn__c": "",
                      "CA10__restApi__c": "test2",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "restApiStageRecordType"
                      },
                      "CA10__accessLoggingDestination__r": {
                          "Id": null,
                          "CA10__disappearanceTime__c": null
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-05T19:15:56Z"
              },
              "Id": "test3",
              "RecordTypeId": "restApiRecordType",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "restApiRecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test3_1",
                      "RecordTypeId": "restApiStageRecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__accessLoggingDestination__c": "",
                      "CA10__accessLoggingDestinationArn__c": "accessLoggingDestinationArn",
                      "CA10__restApi__c": "test3",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "restApiStageRecordType"
                      },
                      "CA10__accessLoggingDestination__r": {
                          "Id": null,
                          "CA10__disappearanceTime__c": null
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "199",
                  "conditionText": "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-05T19:15:56Z"
              },
              "Id": "test4",
              "RecordTypeId": "restApiRecordType",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "restApiRecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test4_1",
                      "RecordTypeId": "restApiStageRecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__accessLoggingDestination__c": "test4_2",
                      "CA10__accessLoggingDestinationArn__c": "accessLoggingDestinationArn",
                      "CA10__restApi__c": "test4",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "restApiStageRecordType"
                      },
                      "CA10__accessLoggingDestination__r": {
                          "Id": "test4_2",
                          "CA10__disappearanceTime__c": "2024-11-05T19:15:56Z"
                      }
                  }
              ]
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-05T19:15:56Z"
              },
              "Id": "test5",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": []
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "200",
                  "conditionText": "otherwise",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-11-05T19:15:56Z"
              },
              "Id": "test6",
              "RecordTypeId": "RecordType",
              "CA10__disappearanceTime__c": null,
              "RecordType": {
                  "DeveloperName": "restApi",
                  "Id": "RecordType"
              },
              "CA10__AWS_API_Gateway_Stages__r": [
                  {
                      "Id": "test6_1",
                      "RecordTypeId": "RecordType",
                      "CA10__disappearanceTime__c": null,
                      "CA10__accessLoggingDestination__c": "test6_2",
                      "CA10__accessLoggingDestinationArn__c": "accessLoggingDestinationArn",
                      "CA10__restApi__c": "test6",
                      "RecordType": {
                          "DeveloperName": "restApiStage",
                          "Id": "RecordType"
                      },
                      "CA10__accessLoggingDestination__r": {
                          "Id": "test6_2",
                          "CA10__disappearanceTime__c": null
                      }
                  }
              ]
          }
      ]
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" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "199",
      "conditionText" : "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "200",
      "conditionText" : "otherwise",
      "runtimeError" : null
    }
  } ];
  """;

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

  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-05T19:15:56Z")
    },
    "DeveloperName" : "restApiStage",
    "Id" : "RecordType"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "DeveloperName" : "restApi",
    "Id" : "restApiRecordType"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "DeveloperName" : "restApiStage",
    "Id" : "restApiStageRecordType"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayStage__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__accessLoggingDestination__c STRING,
      CA10__accessLoggingDestinationArn__c STRING,
      CA10__restApi__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test1_1",
    "RecordTypeId" : "RecordType",
    "CA10__accessLoggingDestination__c" : "",
    "CA10__accessLoggingDestinationArn__c" : "",
    "CA10__restApi__c" : "test1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test2_1",
    "RecordTypeId" : "restApiStageRecordType",
    "CA10__accessLoggingDestination__c" : "",
    "CA10__accessLoggingDestinationArn__c" : "",
    "CA10__restApi__c" : "test2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test3_1",
    "RecordTypeId" : "restApiStageRecordType",
    "CA10__accessLoggingDestination__c" : "",
    "CA10__accessLoggingDestinationArn__c" : "accessLoggingDestinationArn",
    "CA10__restApi__c" : "test3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test4_1",
    "RecordTypeId" : "restApiStageRecordType",
    "CA10__accessLoggingDestination__c" : "test4_2",
    "CA10__accessLoggingDestinationArn__c" : "accessLoggingDestinationArn",
    "CA10__restApi__c" : "test4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test6_1",
    "RecordTypeId" : "RecordType",
    "CA10__accessLoggingDestination__c" : "test6_2",
    "CA10__accessLoggingDestinationArn__c" : "accessLoggingDestinationArn",
    "CA10__restApi__c" : "test6"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsCloudWatchLogsLogGroup__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test4_2",
    "CA10__disappearanceTime__c" : new Date("2024-11-05T19:15:56Z")
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-11-05T19:15:56Z")
    },
    "Id" : "test6_2"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsApiGatewayRestApi__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__AWS_API_Gateway_Stages__r ARRAY<STRUCT<
              Id STRING,
              RecordTypeId STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__accessLoggingDestination__c STRING,
              CA10__accessLoggingDestinationArn__c STRING,
              CA10__restApi__c STRING,
              RecordType STRUCT<
                  DeveloperName STRING,
                  Id STRING
              >,
              CA10__accessLoggingDestination__r STRUCT<
                  Id STRING,
                  CA10__disappearanceTime__c TIMESTAMP
              >,
              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 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};
      }
      var count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT2 = 0;
      if (obj.CA10__AWS_API_Gateway_Stages__r != null) {
          for (var i3 = 0; i3 < obj.CA10__AWS_API_Gateway_Stages__r.length; i3++) {
              if (obj.CA10__AWS_API_Gateway_Stages__r[i3].result.status == 'INCOMPLIANT') {
                  count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT2 += 1;
              }
          }
      }
      // condition[1], conditionIndex:[100..199]
      references1.push('Related list [CA10__AWS_API_Gateway_Stages__r] ' + (count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT2 > 0 ? 'has' : 'does not have') + ' objects in INCOMPLIANT status');
      if (count_CA10__AWS_API_Gateway_Stages__r_INCOMPLIANT2 > 0) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "CA10__AWS_API_Gateway_Stages__r.has(INCOMPLIANT)", currentStateMessage: "There is at least one related API Stage where CloudWatch Access Logs are not enabled.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling CloudWatch Access Logs for the API Stage.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, 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__accessLoggingDestination__c STRING,
          CA10__accessLoggingDestinationArn__c STRING,
          CA10__restApi__c STRING,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__accessLoggingDestination__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP
          >
      >,
      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]
      if (TextLib.isEmpty(obj.CA10__accessLoggingDestinationArn__c) || TextLib.isEmpty(obj.CA10__accessLoggingDestination__c) || obj.CA10__accessLoggingDestination__r.CA10__disappearanceTime__c != null) {
          return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "isEmptyLookup('CA10__accessLoggingDestination__r')", currentStateMessage: "CloudWatch Access Logs are not enabled for this API Stage.", currentStateReferences: references1.join('\n'), remediation: "Consider enabling CloudWatch Access Logs for this API Stage.", runtimeError: null};
      }
      return {status: 'COMPLIANT', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "CloudWatch Access 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,
          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,
                  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__accessLoggingDestination__c AS CA10__accessLoggingDestination__c,
                      sObject.CA10__accessLoggingDestinationArn__c AS CA10__accessLoggingDestinationArn__c,
                      sObject.CA10__restApi__c AS CA10__restApi__c,
                      STRUCT (
                          `RecordType`.DeveloperName AS DeveloperName,
                          `RecordType`.Id AS Id
                      ) AS RecordType,
                      STRUCT (
                          `CA10__accessLoggingDestination__r`.Id AS Id,
                          `CA10__accessLoggingDestination__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
                      ) AS CA10__accessLoggingDestination__r,
                      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__accessLoggingDestination__c AS CA10__accessLoggingDestination__c,
                              sObject.CA10__accessLoggingDestinationArn__c AS CA10__accessLoggingDestinationArn__c,
                              sObject.CA10__restApi__c AS CA10__restApi__c,
                              STRUCT (
                                  `RecordType`.DeveloperName AS DeveloperName,
                                  `RecordType`.Id AS Id
                              ) AS RecordType,
                              STRUCT (
                                  `CA10__accessLoggingDestination__r`.Id AS Id,
                                  `CA10__accessLoggingDestination__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
                              ) AS CA10__accessLoggingDestination__r
                          ),
                          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
          LEFT JOIN UNNEST(mock_CA10__CaAwsCloudWatchLogsLogGroup__c()) AS `CA10__accessLoggingDestination__r`
              ON sObject.CA10__accessLoggingDestination__c = `CA10__accessLoggingDestination__r`.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;
