---
inputType: "CA10A1__CaAwsSageMakerEndpoint__c"
testData:
  - file: "test-data.json"
importExtracts:
  - file: "/types/CA10A1__CaAwsSageMakerEndpoint__c/object.extracts.yaml"
  - file: "/types/CA10A1__CaAwsSageMakerEndpointConfig__c/object.extracts.yaml"
conditions:
  - status: "INAPPLICABLE"
    currentStateMessage: "The SageMaker Endpoint is not in service."
    check:
      NOT_EQUAL:
        left:
          EXTRACT: "CA10A1__status__c"
        right:
          TEXT: "InService"
  - status: "UNDETERMINED"
    currentStateMessage: "The Endpoint Configuration or its production variants are not present in the CMDB."
    check:
      IS_EMPTY_LOOKUP: "CA10A1__endpointConfig__r"
  - status: "INCOMPLIANT"
    currentStateMessage: "At least one production variant in the endpoint configuration has an instance count less than 2."
    remediationMessage: "Increase the instance count for all production variants to at least 2."
    check:
      # Evaluates the JSON array of variants to see if any have initialInstanceCount < 2
      GREATER_THAN:
        left:
          JSON_QUERY_NUMBER:
            arg:
              EXTRACT: "caJsonFrom__productionVariantsJson__c"
            expression: "length([?initialInstanceCount < `2`])"
            undeterminedIf:
              evaluationError: "Failed to query the production variants JSON."
              resultTypeMismatch: "Query did not return a number."
        right:
          NUMBER: 0
  - status: "COMPLIANT"
    currentStateMessage: "All production variants for this endpoint have at least two instances configured."
    check:
      # Evaluates the JSON array of variants to see if any have initialInstanceCount > 1
      GREATER_THAN:
        left:
          JSON_QUERY_NUMBER:
            arg:
              EXTRACT: "caJsonFrom__productionVariantsJson__c"
            expression: "length([?initialInstanceCount > `1`])"
            undeterminedIf:
              evaluationError: "Failed to query the production variants JSON."
              resultTypeMismatch: "Query did not return a number."
        right:
          NUMBER: 0
otherwise:
  status: "UNDETERMINED"
  currentStateMessage: "Unable to determine the initial instance count of the Endpoint Config."