---
inputType: "CA10__CaAzureAccount__c"
importExtracts:
  - file: /types/CA10__CaAzureAccount__c/object.extracts.yaml
testData:
  - file: "test-data.json"
conditions:
# only one Network Watcher per region is allowed
  - status: "INCOMPLIANT"
    currentStateMessage: "Network Watcher is not enabled for every available region in the Subscription."
    remediationMessage: "Consider enabling Network Watcher for all available regions in the Subscription."
    check:
      GREATER_THAN:
        left:
          JSON_QUERY_NUMBER:
            arg:
              EXTRACT: "caJsonFrom_availableLocationNames__c"
            expression: "length(values)"
            undeterminedIf:
              evaluationError: "The JSON query has failed."
              resultTypeMismatch: "The JSON query did not return a number type."
        right:
          RELATED_LIST_COUNT:
            relationshipName: "CA10__Azure_Network_Watchers__r"
            status: "COMPLIANT"
  - status: "COMPLIANT"
    currentStateMessage: "Network Watcher is enabled for every available region in the Subscription."
    check:
      LESS_THAN_EQUAL:
        left:
          JSON_QUERY_NUMBER:
            arg:
              EXTRACT: "caJsonFrom_availableLocationNames__c"
            expression: "length(values)"
            undeterminedIf:
              evaluationError: "The JSON query has failed."
              resultTypeMismatch: "The JSON query did not return a number type."
        right:
          RELATED_LIST_COUNT:
            relationshipName: "CA10__Azure_Network_Watchers__r"
            status: "COMPLIANT"
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unexpected values in the fields."
relatedLists:
  - relationshipName: "CA10__Azure_Network_Watchers__r"
    importExtracts:
      - file: "/types/CA10__CaAzureNetworkWatcher__c/object.extracts.yaml"
    conditions:
      - status: "COMPLIANT"
        currentStateMessage: "Network Watcher is provisioned successfully."
        check:
          IS_EQUAL:
            left:
              EXTRACT: "CA10__provisioningState__c"
            right:
              TEXT: "Succeeded"
    otherwise:
      status: "INCOMPLIANT"
      currentStateMessage: "Network Watcher was not provisioned successfully."
      remediationMessage: "Try restoring Network Watcher succeeded state."
