---
policy: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate
logic: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/prod.logic.yaml
executionTime: 2025-04-24T23:44:20.745704888Z
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: "not(['restApiStage'].contains(RecordType.DeveloperName))"
      actual: "not(['restApiStage'].contains(RecordType.DeveloperName))"
    runtimeError: {}
  - id: test3
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 299
      actual: 299
    conditionText:
      expected: extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'
      actual: extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'
    runtimeError: {}
  - id: test4
    match: true
    status:
      expected: INAPPLICABLE
      actual: INAPPLICABLE
    conditionIndex:
      expected: 399
      actual: 399
    conditionText:
      expected: CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)
      actual: CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)
    runtimeError: {}
  - id: test5
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: isEmptyLookup('CA10__clientCertificate__r')
      actual: isEmptyLookup('CA10__clientCertificate__r')
    runtimeError: {}
  - id: test6
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: isEmptyLookup('CA10__clientCertificate__r')
      actual: isEmptyLookup('CA10__clientCertificate__r')
    runtimeError: {}
  - id: test7
    match: true
    status:
      expected: INCOMPLIANT
      actual: INCOMPLIANT
    conditionIndex:
      expected: 499
      actual: 499
    conditionText:
      expected: isEmptyLookup('CA10__clientCertificate__r')
      actual: isEmptyLookup('CA10__clientCertificate__r')
    runtimeError: {}
  - id: test8
    match: true
    status:
      expected: COMPLIANT
      actual: COMPLIANT
    conditionIndex:
      expected: 599
      actual: 599
    conditionText:
      expected: notEmptyLookup('CA10__clientCertificate__r')
      actual: notEmptyLookup('CA10__clientCertificate__r')
    runtimeError: {}
usedFiles:
  - path: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/policy.yaml
    md5Hash: 9C33486220F93D978B807D552A64FE95
    content: "---\nnames:\n  full: AWS API Gateway REST API Stage is not configured\
      \ to use an SSL certificate for authentication\n  contextual: REST API Stage\
      \ is not configured to use an SSL certificate for authentication\ndescription:\
      \ >\n  Ensure that the REST API Stage in AWS API Gateway is configured to use\
      \ an SSL \n  certificate for authentication. This ensures secure communication\
      \ between \n  backend systems and the API Gateway.\ncategories:\n  - \"SECURITY\"\
      \ntype: \"COMPLIANCE_POLICY\"\nframeworkMappings:\n  - \"/frameworks/cloudaware/resource-security/data-encryption\"\
      \n  - \"/frameworks/aws-fsbp-v1.0.0/api-gateway/02\"\nsimilarPolicies:\n  internal:\n\
      \    - \"dec-x-d9d39f21\""
  - path: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/prod.logic.yaml
    md5Hash: F55F8E3578AA1136D16F01215943B31D
    content: |
      ---
      inputType: "CA10__CaAwsApiGatewayStage__c"
      importExtracts:
        - file: "/types/CA10__CaAwsApiGatewayRestApi__c/object.extracts.yaml"
      testData:
        - file: test-data.json
      recordTypes:
        - "restApiStage"
      conditions:
        - status: "INAPPLICABLE"
          currentStateMessage: "The Stage belongs to a private API endpoint."
          check:
            IS_EQUAL:
              left:
                EXTRACT: "CA10__restApi__r.CA10__endpointType__c"
              right:
                TEXT: "PRIVATE"
        - status: "INAPPLICABLE"
          currentStateMessage: "The Stage doesn't have HTTP integrations."
          check:
            RELATED_LIST_HAS_NO:
              status: "COMPLIANT"
              relationshipName: "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r"
        - status: "INCOMPLIANT"
          currentStateMessage: "The Stage is not configured to use an SSL certificate."
          remediationMessage: "Consider generating an SSL certificate for authentication."
          check:
            IS_EMPTY_LOOKUP: "CA10__clientCertificate__r"
        - status: "COMPLIANT"
          currentStateMessage: "The Stage is configured to use an SSL certificate."
          check:
            NOT_EMPTY_LOOKUP: "CA10__clientCertificate__r"
      otherwise:
        status: "UNDETERMINED"
        currentStateMessage: "Unexpected values in the fields."
      relatedLists:
        - relationshipName: "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r"
          importExtracts:
          - file: "/types/CA10A1__CaAwsApiGatewayMethod__c/object.extracts.yaml"
          conditions:
            - status: "COMPLIANT"
              currentStateMessage: "This is an HTTP integration."
              check:
                OR:
                  args:
                    - IS_EQUAL:
                        left:
                          EXTRACT: "CA10A1__integrationType__c"
                        right:
                          TEXT: "HTTP"
                    - IS_EQUAL:
                        left:
                          EXTRACT: "CA10A1__integrationType__c"
                        right:
                          TEXT: "HTTP_PROXY"
          otherwise:
            status: "INAPPLICABLE"
            currentStateMessage: "This is not an HTTP integration."
  - path: /ce/ca/aws/apigateway/rest-api-stage-ssl-certificate/test-data.json
    md5Hash: 6A90FE9B918330B473DDC7C73CDA2D15
    content: |-
      [
          {
              "expectedResult": {
                  "status": "DISAPPEARED",
                  "conditionIndex": "99",
                  "conditionText": "isDisappeared(CA10__disappearanceTime__c)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test1",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": "2024-12-10T20:07:16Z",
              "CA10__restApi__c": "restApi1",
              "CA10__restApiId__c": "restApiId1",
              "CA10__clientCertificate__c": "clientCertificate1",
              "CA10__clientCertificateId__c": "clientCertificateId1",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi1",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test1_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP",
                          "CA10A1__restApi__c": "restApi1"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": "clientCertificate1",
                  "CA10__disappearanceTime__c": null
              }
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "199",
                  "conditionText": "not(['restApiStage'].contains(RecordType.DeveloperName))",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test2",
              "RecordTypeId": "RecordTypeId2",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi2",
              "CA10__restApiId__c": "restApiId2",
              "CA10__clientCertificate__c": "clientCertificate2",
              "CA10__clientCertificateId__c": "clientCertificateId2",
              "RecordType": {
                  "DeveloperName": "httpApiStage",
                  "Id": "RecordTypeId2"
              },
              "CA10__restApi__r": {
                  "Id": "restApi2",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test2_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP",
                          "CA10A1__restApi__c": "restApi2"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": "clientCertificate2",
                  "CA10__disappearanceTime__c": null
              }
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "299",
                  "conditionText": "extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test3",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi3",
              "CA10__restApiId__c": "restApiId3",
              "CA10__clientCertificate__c": "clientCertificate3",
              "CA10__clientCertificateId__c": "clientCertificateId3",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi3",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "PRIVATE",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test3_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP",
                          "CA10A1__restApi__c": "restApi3"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": "clientCertificate3",
                  "CA10__disappearanceTime__c": null
              }
          },
          {
              "expectedResult": {
                  "status": "INAPPLICABLE",
                  "conditionIndex": "399",
                  "conditionText": "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test4",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi4",
              "CA10__restApiId__c": "restApiId4",
              "CA10__clientCertificate__c": "clientCertificate4",
              "CA10__clientCertificateId__c": "clientCertificateId4",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi4",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test4_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "AWS",
                          "CA10A1__restApi__c": "restApi4"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": "clientCertificate4",
                  "CA10__disappearanceTime__c": null
              }
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "isEmptyLookup('CA10__clientCertificate__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test5",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi5",
              "CA10__restApiId__c": "restApiId5",
              "CA10__clientCertificate__c": "clientCertificate5",
              "CA10__clientCertificateId__c": "clientCertificateId5",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi5",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test5_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP",
                          "CA10A1__restApi__c": "restApi5"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": "clientCertificate5",
                  "CA10__disappearanceTime__c": "2024-12-10T20:07:16Z"
              }
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "isEmptyLookup('CA10__clientCertificate__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test6",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi6",
              "CA10__restApiId__c": "restApiId6",
              "CA10__clientCertificate__c": "",
              "CA10__clientCertificateId__c": "clientCertificateId6",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi6",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test6_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP_PROXY",
                          "CA10A1__restApi__c": "restApi6"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": null,
                  "CA10__disappearanceTime__c": null
              }
          },
          {
              "expectedResult": {
                  "status": "INCOMPLIANT",
                  "conditionIndex": "499",
                  "conditionText": "isEmptyLookup('CA10__clientCertificate__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test7",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi7",
              "CA10__restApiId__c": "restApiId7",
              "CA10__clientCertificate__c": "",
              "CA10__clientCertificateId__c": "",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi7",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test7_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP_PROXY",
                          "CA10A1__restApi__c": "restApi7"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": null,
                  "CA10__disappearanceTime__c": null
              }
          },
          {
              "expectedResult": {
                  "status": "COMPLIANT",
                  "conditionIndex": "599",
                  "conditionText": "notEmptyLookup('CA10__clientCertificate__r')",
                  "runtimeError": null
              },
              "context": {
                  "snapshotTime": "2024-12-10T20:07:16Z"
              },
              "Id": "test8",
              "RecordTypeId": "RecordTypeId",
              "CA10__disappearanceTime__c": null,
              "CA10__restApi__c": "restApi8",
              "CA10__restApiId__c": "restApiId8",
              "CA10__clientCertificate__c": "clientCertificateId8",
              "CA10__clientCertificateId__c": "clientCertificateId8",
              "RecordType": {
                  "DeveloperName": "restApiStage",
                  "Id": "RecordTypeId"
              },
              "CA10__restApi__r": {
                  "Id": "restApi8",
                  "CA10__disappearanceTime__c": null,
                  "CA10__endpointType__c": "REGIONAL",
                  "CA10A1__AWS_API_Gateway_Methods__r": [
                      {
                          "Id": "test8_1",
                          "CA10A1__disappearanceTime__c": null,
                          "CA10A1__integrationType__c": "HTTP_PROXY",
                          "CA10A1__restApi__c": "restApi8"
                      }
                  ]
              },
              "CA10__clientCertificate__r": {
                  "Id": "clientCertificateId8",
                  "CA10__disappearanceTime__c": null
              }
          }
      ]
  - path: /types/CA10A1__CaAwsApiGatewayMethod__c/object.extracts.yaml
    md5Hash: E28695D16341F6C70D3B2EE06BCEB425
    content: "---\nextracts:\n#Values: HTTP | AWS | MOCK | HTTP_PROXY | AWS_PROXY.\
      \ Not Nullable. Can't have no access, retrieved via apigateway:GetMethod.\n\
      \  - name: CA10A1__integrationType__c\n    value: \n      FIELD:\n        path:\
      \ CA10A1__integrationType__c\n        undeterminedIf:\n          isEmpty: \"\
      Integration Type cannot be empty. Possibly corrupted data.\""
  - 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" : "not(['restApiStage'].contains(RecordType.DeveloperName))",
      "runtimeError" : null
    }
  }, {
    "Id" : "test3",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "299",
      "conditionText" : "extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'",
      "runtimeError" : null
    }
  }, {
    "Id" : "test4",
    "expectedResult" : {
      "status" : "INAPPLICABLE",
      "conditionIndex" : "399",
      "conditionText" : "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)",
      "runtimeError" : null
    }
  }, {
    "Id" : "test5",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "isEmptyLookup('CA10__clientCertificate__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test6",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "isEmptyLookup('CA10__clientCertificate__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test7",
    "expectedResult" : {
      "status" : "INCOMPLIANT",
      "conditionIndex" : "499",
      "conditionText" : "isEmptyLookup('CA10__clientCertificate__r')",
      "runtimeError" : null
    }
  }, {
    "Id" : "test8",
    "expectedResult" : {
      "status" : "COMPLIANT",
      "conditionIndex" : "599",
      "conditionText" : "notEmptyLookup('CA10__clientCertificate__r')",
      "runtimeError" : null
    }
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayStage__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      RecordTypeId STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__restApi__c STRING,
      CA10__restApiId__c STRING,
      CA10__clientCertificate__c STRING,
      CA10__clientCertificateId__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test1",
    "RecordTypeId" : "RecordTypeId",
    "CA10__disappearanceTime__c" : new Date("2024-12-10T20:07:16Z"),
    "CA10__restApi__c" : "restApi1",
    "CA10__restApiId__c" : "restApiId1",
    "CA10__clientCertificate__c" : "clientCertificate1",
    "CA10__clientCertificateId__c" : "clientCertificateId1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test2",
    "RecordTypeId" : "RecordTypeId2",
    "CA10__restApi__c" : "restApi2",
    "CA10__restApiId__c" : "restApiId2",
    "CA10__clientCertificate__c" : "clientCertificate2",
    "CA10__clientCertificateId__c" : "clientCertificateId2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test3",
    "RecordTypeId" : "RecordTypeId",
    "CA10__restApi__c" : "restApi3",
    "CA10__restApiId__c" : "restApiId3",
    "CA10__clientCertificate__c" : "clientCertificate3",
    "CA10__clientCertificateId__c" : "clientCertificateId3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test4",
    "RecordTypeId" : "RecordTypeId",
    "CA10__restApi__c" : "restApi4",
    "CA10__restApiId__c" : "restApiId4",
    "CA10__clientCertificate__c" : "clientCertificate4",
    "CA10__clientCertificateId__c" : "clientCertificateId4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test5",
    "RecordTypeId" : "RecordTypeId",
    "CA10__restApi__c" : "restApi5",
    "CA10__restApiId__c" : "restApiId5",
    "CA10__clientCertificate__c" : "clientCertificate5",
    "CA10__clientCertificateId__c" : "clientCertificateId5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test6",
    "RecordTypeId" : "RecordTypeId",
    "CA10__restApi__c" : "restApi6",
    "CA10__restApiId__c" : "restApiId6",
    "CA10__clientCertificate__c" : "",
    "CA10__clientCertificateId__c" : "clientCertificateId6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test7",
    "RecordTypeId" : "RecordTypeId",
    "CA10__restApi__c" : "restApi7",
    "CA10__restApiId__c" : "restApiId7",
    "CA10__clientCertificate__c" : "",
    "CA10__clientCertificateId__c" : ""
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test8",
    "RecordTypeId" : "RecordTypeId",
    "CA10__restApi__c" : "restApi8",
    "CA10__restApiId__c" : "restApiId8",
    "CA10__clientCertificate__c" : "clientCertificateId8",
    "CA10__clientCertificateId__c" : "clientCertificateId8"
  } ];
  """;

  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-12-10T20:07:16Z")
    },
    "DeveloperName" : "restApiStage",
    "Id" : "RecordTypeId"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "DeveloperName" : "httpApiStage",
    "Id" : "RecordTypeId2"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayRestApi__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10__disappearanceTime__c TIMESTAMP,
      CA10__endpointType__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi1",
    "CA10__endpointType__c" : "REGIONAL"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi2",
    "CA10__endpointType__c" : "REGIONAL"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi3",
    "CA10__endpointType__c" : "PRIVATE"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi4",
    "CA10__endpointType__c" : "REGIONAL"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi5",
    "CA10__endpointType__c" : "REGIONAL"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi6",
    "CA10__endpointType__c" : "REGIONAL"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi7",
    "CA10__endpointType__c" : "REGIONAL"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "restApi8",
    "CA10__endpointType__c" : "REGIONAL"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10A1__CaAwsApiGatewayMethod__c()
  RETURNS ARRAY<STRUCT<
      Id STRING,
      CA10A1__disappearanceTime__c TIMESTAMP,
      CA10A1__integrationType__c STRING,
      CA10A1__restApi__c STRING,
      context STRUCT<
          snapshotTime TIMESTAMP
      >
  >>
  DETERMINISTIC
  LANGUAGE js
  AS r"""
    return [ {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test1_1",
    "CA10A1__integrationType__c" : "HTTP",
    "CA10A1__restApi__c" : "restApi1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test2_1",
    "CA10A1__integrationType__c" : "HTTP",
    "CA10A1__restApi__c" : "restApi2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test3_1",
    "CA10A1__integrationType__c" : "HTTP",
    "CA10A1__restApi__c" : "restApi3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test4_1",
    "CA10A1__integrationType__c" : "AWS",
    "CA10A1__restApi__c" : "restApi4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test5_1",
    "CA10A1__integrationType__c" : "HTTP",
    "CA10A1__restApi__c" : "restApi5"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test6_1",
    "CA10A1__integrationType__c" : "HTTP_PROXY",
    "CA10A1__restApi__c" : "restApi6"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test7_1",
    "CA10A1__integrationType__c" : "HTTP_PROXY",
    "CA10A1__restApi__c" : "restApi7"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "test8_1",
    "CA10A1__integrationType__c" : "HTTP_PROXY",
    "CA10A1__restApi__c" : "restApi8"
  } ];
  """;

  CREATE TEMP FUNCTION mock_CA10__CaAwsApiGatewayClientCertificate__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-12-10T20:07:16Z")
    },
    "Id" : "clientCertificate1"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "clientCertificate2"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "clientCertificate3"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "clientCertificate4"
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "clientCertificate5",
    "CA10__disappearanceTime__c" : new Date("2024-12-10T20:07:16Z")
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : null
  }, {
    "context" : {
      "snapshotTime" : new Date("2024-12-10T20:07:16Z")
    },
    "Id" : "clientCertificateId8"
  } ];
  """;

  CREATE TEMP FUNCTION process_CA10__CaAwsApiGatewayStage__c(
      obj STRUCT<
          Id STRING,
          RecordTypeId STRING,
          CA10__disappearanceTime__c TIMESTAMP,
          CA10__restApi__c STRING,
          CA10__restApiId__c STRING,
          CA10__clientCertificate__c STRING,
          CA10__clientCertificateId__c STRING,
          RecordType STRUCT<
              DeveloperName STRING,
              Id STRING
          >,
          CA10__restApi__r STRUCT<
              Id STRING,
              CA10__disappearanceTime__c TIMESTAMP,
              CA10__endpointType__c STRING,
              CA10A1__AWS_API_Gateway_Methods__r ARRAY<STRUCT<
                  Id STRING,
                  CA10A1__disappearanceTime__c TIMESTAMP,
                  CA10A1__integrationType__c STRING,
                  CA10A1__restApi__c STRING,
                  result STRUCT<status STRING, conditionIndex DECIMAL, conditionText STRING, currentStateMessage STRING, currentStateReferences STRING, remediation STRING, runtimeError STRING>
              >>
          >,
          CA10__clientCertificate__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 CollectionLib = new function () {
          this.parse = function(arg, separator) {
              let out = new Set();
              if (arg == null) {
                  return out;
              }
              arg.split(separator).forEach(el => {if (TextLib.isNotEmpty(el)) {out.add(TextLib.normalize(el))}});
              return out;
          };
          this.fromArray = function(arr) {
              let out = new Set();
              if (arr == null) {
                  return out;
              }
              arr.forEach(el => {if (TextLib.isNotEmpty(el)) {out.add(TextLib.normalize(el))}});
              return out;
          };
          this.equal = function(left, right) {
              left = left == null ? new Set() : left;
              right = right == null ? new Set() : right;
              return left.size === right.size && new Set([...left, ...right]).size === left.size;
          };
          this.notEqual = function(left, right) {
              left = left == null ? new Set() : left;
              right = right == null ? new Set() : right;
              return left.size !== right.size || new Set([...left, ...right]).size !== left.size;
          };
          this.contains = function(collection, search) {
              if (collection == null || TextLib.isEmpty(search)) {
                  return false;
              }
              return collection.has(TextLib.normalize(search));
          };
          this.size = function(collection) {
              return collection == null ? 0 : collection.size;
          };
      }();
      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]
      references1.push('Record Type Name [obj.RecordType.DeveloperName]: ' + obj.RecordType.DeveloperName);
      if (!CollectionLib.contains(CollectionLib.fromArray(['restApiStage']), obj.RecordType.DeveloperName)) {
          return {status: 'INAPPLICABLE', conditionIndex: 199, conditionText: "not(['restApiStage'].contains(RecordType.DeveloperName))", currentStateMessage: "Object record type is not applicable", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[2], conditionIndex:[200..299]
      function extractChecked3() {
          if (TextLib.isEmpty(obj.CA10__restApiId__c)) {
              throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "extractCheck(obj.CA10__restApiId__c)", currentStateMessage: "Related object via CA10__restApiId__c has empty ID", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (TextLib.isEmpty(obj.CA10__restApi__c)) {
              throw new Error("UNDETERMINED condition:202", {cause: {status: 'UNDETERMINED', conditionIndex: 202, conditionText: "extractCheck(obj.CA10__restApi__c)", currentStateMessage: "Related object via CA10__restApi__c is not present", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          if (obj.CA10__restApi__r.CA10__disappearanceTime__c != null) {
              throw new Error("UNDETERMINED condition:203", {cause: {status: 'UNDETERMINED', conditionIndex: 203, conditionText: "extractCheck(obj.CA10__restApi__r.CA10__disappearanceTime__c)", currentStateMessage: "Related object via CA10__restApi__c is present, but deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return extract4.call(extract4);
      }
      function extract4() { if (!this.out) { this.out = obj.CA10__restApi__r.CA10__endpointType__c; } return this.out; };
      references1.push('Endpoint Type [obj.CA10__restApi__r.CA10__endpointType__c]: ' + obj.CA10__restApi__r.CA10__endpointType__c);
      try {
          if (TextLib.equal(extractChecked3(), 'PRIVATE')) {
              return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10__restApi__r.CA10__endpointType__c') == 'PRIVATE'", currentStateMessage: "The Stage belongs to a private API endpoint.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      var count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 = 0;
      if (obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r != null) {
          for (var i7 = 0; i7 < obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.length; i7++) {
              if (obj.CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r[i7].result.status == 'COMPLIANT') {
                  count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 += 1;
              }
          }
      }
      // condition[3], conditionIndex:[300..399]
      references1.push('Related list [CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r] ' + (count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status');
      if (count_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r_COMPLIANT6 == 0) {
          return {status: 'INAPPLICABLE', conditionIndex: 399, conditionText: "CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r.hasNo(COMPLIANT)", currentStateMessage: "The Stage doesn't have HTTP integrations.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[4], conditionIndex:[400..499]
      if (TextLib.isEmpty(obj.CA10__clientCertificateId__c) || TextLib.isEmpty(obj.CA10__clientCertificate__c) || obj.CA10__clientCertificate__r.CA10__disappearanceTime__c != null) {
          return {status: 'INCOMPLIANT', conditionIndex: 499, conditionText: "isEmptyLookup('CA10__clientCertificate__r')", currentStateMessage: "The Stage is not configured to use an SSL certificate.", currentStateReferences: references1.join('\n'), remediation: "Consider generating an SSL certificate for authentication.", runtimeError: null};
      }
      // condition[5], conditionIndex:[500..599]
      if (TextLib.isNotEmpty(obj.CA10__clientCertificateId__c) && TextLib.isNotEmpty(obj.CA10__clientCertificate__c) && obj.CA10__clientCertificate__r.CA10__disappearanceTime__c == null) {
          return {status: 'COMPLIANT', conditionIndex: 599, conditionText: "notEmptyLookup('CA10__clientCertificate__r')", currentStateMessage: "The Stage is configured to use an SSL certificate.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      return {status: 'UNDETERMINED', conditionIndex: 600, conditionText: "otherwise", currentStateMessage: "Unexpected values in the fields.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
  """;

  CREATE TEMP FUNCTION process_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r(
      obj STRUCT<
          Id STRING,
          CA10A1__disappearanceTime__c TIMESTAMP,
          CA10A1__integrationType__c STRING,
          CA10A1__restApi__c 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 [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c);
      if (obj.CA10A1__disappearanceTime__c != null) {
          return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
      }
      // condition[1], conditionIndex:[100..199]
      function fieldChecked4() {
          if (TextLib.isEmpty(obj.CA10A1__integrationType__c)) {
              throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A1__integrationType__c.isEmpty()", currentStateMessage: "Integration Type cannot be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}});
          }
          return obj.CA10A1__integrationType__c;
      }
      function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; };
      references1.push('Integration Type [obj.CA10A1__integrationType__c]: ' + obj.CA10A1__integrationType__c);
      try {
          if (TextLib.equal(extract3.call(extract3), 'HTTP') || TextLib.equal(extract3.call(extract3), 'HTTP_PROXY')) {
              return {status: 'COMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__integrationType__c') == 'HTTP' || extract('CA10A1__integrationType__c') == 'HTTP_PROXY'", currentStateMessage: "This is an HTTP integration.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null};
          }
      } catch (err) {
          if (err.cause && err.cause.status) { return err.cause; } else { throw err; }
      }
      return {status: 'INAPPLICABLE', conditionIndex: 200, conditionText: "otherwise", currentStateMessage: "This is not an HTTP integration.", 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__restApi__c AS CA10__restApi__c,
          sObject.CA10__restApiId__c AS CA10__restApiId__c,
          sObject.CA10__clientCertificate__c AS CA10__clientCertificate__c,
          sObject.CA10__clientCertificateId__c AS CA10__clientCertificateId__c,
          STRUCT (
              `RecordType`.DeveloperName AS DeveloperName,
              `RecordType`.Id AS Id
          ) AS RecordType,
          STRUCT (
              `CA10__restApi__r`.Id AS Id,
              `CA10__restApi__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
              `CA10__restApi__r`.CA10__endpointType__c AS CA10__endpointType__c,
              `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`.arr AS CA10A1__AWS_API_Gateway_Methods__r
          ) AS CA10__restApi__r,
          STRUCT (
              `CA10__clientCertificate__r`.Id AS Id,
              `CA10__clientCertificate__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
          ) AS CA10__clientCertificate__r,
          process_CA10__CaAwsApiGatewayStage__c(
              STRUCT(
                  sObject.Id AS Id,
                  sObject.RecordTypeId AS RecordTypeId,
                  sObject.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                  sObject.CA10__restApi__c AS CA10__restApi__c,
                  sObject.CA10__restApiId__c AS CA10__restApiId__c,
                  sObject.CA10__clientCertificate__c AS CA10__clientCertificate__c,
                  sObject.CA10__clientCertificateId__c AS CA10__clientCertificateId__c,
                  STRUCT (
                      `RecordType`.DeveloperName AS DeveloperName,
                      `RecordType`.Id AS Id
                  ) AS RecordType,
                  STRUCT (
                      `CA10__restApi__r`.Id AS Id,
                      `CA10__restApi__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c,
                      `CA10__restApi__r`.CA10__endpointType__c AS CA10__endpointType__c,
                      `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`.arr AS CA10A1__AWS_API_Gateway_Methods__r
                  ) AS CA10__restApi__r,
                  STRUCT (
                      `CA10__clientCertificate__r`.Id AS Id,
                      `CA10__clientCertificate__r`.CA10__disappearanceTime__c AS CA10__disappearanceTime__c
                  ) AS CA10__clientCertificate__r
              ),
              sObject.context.snapshotTime
          ) as result
      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__CaAwsApiGatewayRestApi__c()) AS `CA10__restApi__r`
          ON sObject.CA10__restApi__c = `CA10__restApi__r`.Id
      LEFT JOIN UNNEST(mock_CA10__CaAwsApiGatewayClientCertificate__c()) AS `CA10__clientCertificate__r`
          ON sObject.CA10__clientCertificate__c = `CA10__clientCertificate__r`.Id
      LEFT JOIN (
          SELECT
              sObject.CA10A1__restApi__c,
              ARRAY_AGG(
                  STRUCT(
                      sObject.Id AS Id,
                      sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
                      sObject.CA10A1__integrationType__c AS CA10A1__integrationType__c,
                      sObject.CA10A1__restApi__c AS CA10A1__restApi__c,
                      process_CA10__restApi__r_CA10A1__AWS_API_Gateway_Methods__r(
                          STRUCT(
                              sObject.Id AS Id,
                              sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c,
                              sObject.CA10A1__integrationType__c AS CA10A1__integrationType__c,
                              sObject.CA10A1__restApi__c AS CA10A1__restApi__c
                          ),
                          sObject.context.snapshotTime
                      ) as result
                  )
              ) AS arr
          FROM UNNEST(mock_CA10A1__CaAwsApiGatewayMethod__c()) AS sObject
          GROUP BY sObject.CA10A1__restApi__c
      ) AS `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`
          ON `CA10__restApi__r`.Id = `CA10__restApi__r.CA10A1__AWS_API_Gateway_Methods__r`.CA10A1__restApi__c
  ) sObject ON sObject.Id = expectedResult.Id;
