---
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."
