---
inputType: "CA10Z1__CaAzurePostgreSqlServer__c"
testData:
  - file: "test-data.json"
importExtracts:
  - file: "/types/CA10Z1__CaAzurePostgreSqlServer__c/object.extracts.yaml"
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "This is not the Flexible Server deployment mode."
    check:
      NOT_EQUAL:
        left:
          EXTRACT: "CA10Z1__deploymentMode__c"
        right:
          TEXT: "Flexible"
  - status: "INCOMPLIANT"
    currentStateMessage: "PostgreSQL Flexible Server log_checkpoints configuration is not enabled."
    remediationMessage: "Consider enabling PostgreSQL Flexible Server log_checkpoints configuration."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
              arg: 
                EXTRACT: "caJsonFrom__configurations__c"
              expression: "[? name == 'log_checkpoints'].value | [0]"
              undeterminedIf: 
                evaluationError: "The JSON query has failed."
                resultTypeMismatch: "The JSON query did not return text type."
        right:
          TEXT: "off"
  - status: "COMPLIANT"
    currentStateMessage: "PostgreSQL Flexible Server log_checkpoints configuration is enabled."
    check:
      IS_EQUAL:
        left:
          JSON_QUERY_TEXT:
              arg: 
                EXTRACT: "caJsonFrom__configurations__c"
              expression: "[? name == 'log_checkpoints'].value | [0]"
              undeterminedIf: 
                evaluationError: "The JSON query has failed."
                resultTypeMismatch: "The JSON query did not return text type."
        right:
          TEXT: "on"
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unexpected value in the field."