--- policy: /ce/ca/azure/api-management/no-active-apis logic: /ce/ca/azure/api-management/no-active-apis/prod.logic.yaml executionTime: 2026-09-22T15:06:28.816580441Z generationMs: 61 executionMs: 1008 rows: - id: gone match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10Z1__disappearanceTime__c) actual: isDisappeared(CA10Z1__disappearanceTime__c) runtimeError: {} - id: missing-provisioning-state match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10Z1__provisioningState__c').isEmpty() actual: extract('CA10Z1__provisioningState__c').isEmpty() runtimeError: {} - id: updating match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10Z1__provisioningState__c') != 'Succeeded' actual: extract('CA10Z1__provisioningState__c') != 'Succeeded' runtimeError: {} - id: missing-sku match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 399 actual: 399 conditionText: expected: extract('CA10Z1__skuName__c').isEmpty() actual: extract('CA10Z1__skuName__c').isEmpty() runtimeError: {} - id: consumption match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 499 actual: 499 conditionText: expected: extract('CA10Z1__skuName__c') == 'Consumption' actual: extract('CA10Z1__skuName__c') == 'Consumption' runtimeError: {} - id: missing-created-at match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 599 actual: 599 conditionText: expected: extract('CA10Z1__createdAtUtc__c').isEmpty() actual: extract('CA10Z1__createdAtUtc__c').isEmpty() runtimeError: {} - id: age-boundary match: true status: expected: INAPPLICABLE actual: INAPPLICABLE conditionIndex: expected: 699 actual: 699 conditionText: expected: extract('CA10Z1__createdAtUtc__c').withinLastDays(30) actual: extract('CA10Z1__createdAtUtc__c').withinLastDays(30) runtimeError: {} - id: empty match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 799 actual: 799 conditionText: expected: CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT) actual: CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT) runtimeError: {} - id: only-disappeared-api match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 799 actual: 799 conditionText: expected: CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT) actual: CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT) runtimeError: {} - id: active-api match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 800 actual: 800 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/azure/api-management/no-active-apis/policy.yaml md5Hash: F761C7BDB922D2714D3B629CA940D936 content: | --- names: full: "Azure API Management service in a capacity-based tier has no active APIs" contextual: "Capacity-based service has no active APIs" description: "Identify successfully provisioned Azure API Management services in non-Consumption tiers, older than 30 days, with no active APIs." categories: - "COST" type: "COMPLIANCE_POLICY" frameworkMappings: - "/frameworks/cloudaware/cost-efficiency-and-optimization/waste-reduction" - path: /ce/ca/azure/api-management/no-active-apis/prod.logic.yaml md5Hash: D330ADFC70E92DE353DA8C70D4415FE3 content: | --- inputType: "CA10Z1__CaAzureApiManagementService__c" testData: - file: "test-data.json" importExtracts: - file: "/types/CA10Z1__CaAzureApiManagementService__c/object.extracts.yaml" conditions: - status: "UNDETERMINED" currentStateMessage: "Provisioning state is unavailable." check: IS_EMPTY: arg: EXTRACT: "CA10Z1__provisioningState__c" - status: "INAPPLICABLE" currentStateMessage: "The API Management service is not successfully provisioned." check: NOT_EQUAL: left: EXTRACT: "CA10Z1__provisioningState__c" right: TEXT: "Succeeded" - status: "UNDETERMINED" currentStateMessage: "SKU is unavailable." check: IS_EMPTY: arg: EXTRACT: "CA10Z1__skuName__c" - status: "INAPPLICABLE" currentStateMessage: "The API Management service uses the Consumption tier." check: IS_EQUAL: left: EXTRACT: "CA10Z1__skuName__c" right: TEXT: "Consumption" - status: "UNDETERMINED" currentStateMessage: "Creation time is unavailable." check: IS_EMPTY: arg: EXTRACT: "CA10Z1__createdAtUtc__c" - status: "INAPPLICABLE" currentStateMessage: "The API Management service is within its first 30 days." check: IS_WITHIN_LAST_DAYS: offsetDays: 30 arg: EXTRACT: "CA10Z1__createdAtUtc__c" - status: "INCOMPLIANT" currentStateMessage: "The non-Consumption API Management service has no active APIs." remediationMessage: "Verify the API inventory in Azure, then remove the service if it is unused." check: RELATED_LIST_HAS_NO: status: "COMPLIANT" relationshipName: "CA10Z1__Azure_API_Management_APIs__r" otherwise: status: "COMPLIANT" currentStateMessage: "The non-Consumption API Management service has at least one active API." relatedLists: - relationshipName: "CA10Z1__Azure_API_Management_APIs__r" conditions: [] otherwise: status: "COMPLIANT" currentStateMessage: "This API record is active in Cloudaware CMDB." - path: /ce/ca/azure/api-management/no-active-apis/test-data.json md5Hash: 1AA3D36758EB9D6BA37E1E378867D2C2 content: |- [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10Z1__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "gone", "CA10Z1__disappearanceTime__c": "2026-09-14T00:00:00Z", "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "199", "conditionText": "extract('CA10Z1__provisioningState__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "missing-provisioning-state", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "299", "conditionText": "extract('CA10Z1__provisioningState__c') != 'Succeeded'", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "updating", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "Updating", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "399", "conditionText": "extract('CA10Z1__skuName__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "missing-sku", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "499", "conditionText": "extract('CA10Z1__skuName__c') == 'Consumption'", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "consumption", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Consumption", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "599", "conditionText": "extract('CA10Z1__createdAtUtc__c').isEmpty()", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "missing-created-at", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": null, "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "INAPPLICABLE", "conditionIndex": "699", "conditionText": "extract('CA10Z1__createdAtUtc__c').withinLastDays(30)", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "age-boundary", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-08-16T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "799", "conditionText": "CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "empty", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-08-15T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [] }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "799", "conditionText": "CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT)", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "only-disappeared-api", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Developer", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [ { "Id": "api-gone", "CA10Z1__disappearanceTime__c": "2026-09-14T00:00:00Z", "CA10Z1__service__c": "only-disappeared-api" } ] }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "800", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-09-15T00:00:00Z" }, "Id": "active-api", "CA10Z1__disappearanceTime__c": null, "CA10Z1__skuName__c": "Standard", "CA10Z1__provisioningState__c": "Succeeded", "CA10Z1__createdAtUtc__c": "2026-01-01T00:00:00Z", "CA10Z1__Azure_API_Management_APIs__r": [ { "Id": "api-active", "CA10Z1__disappearanceTime__c": null, "CA10Z1__service__c": "active-api" } ] } ] - path: /types/CA10Z1__CaAzureApiManagementService__c/object.extracts.yaml md5Hash: B952BD8DD43509E9EEA57E650ACDA9AD content: | --- extracts: - name: "CA10Z1__skuName__c" value: FIELD: path: "CA10Z1__skuName__c" - name: "CA10Z1__provisioningState__c" value: FIELD: path: "CA10Z1__provisioningState__c" - name: "CA10Z1__createdAtUtc__c" value: FIELD: path: "CA10Z1__createdAtUtc__c" script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "gone", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10Z1__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "missing-provisioning-state", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "199", "conditionText" : "extract('CA10Z1__provisioningState__c').isEmpty()", "runtimeError" : null } }, { "Id" : "updating", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "299", "conditionText" : "extract('CA10Z1__provisioningState__c') != 'Succeeded'", "runtimeError" : null } }, { "Id" : "missing-sku", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "399", "conditionText" : "extract('CA10Z1__skuName__c').isEmpty()", "runtimeError" : null } }, { "Id" : "consumption", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "499", "conditionText" : "extract('CA10Z1__skuName__c') == 'Consumption'", "runtimeError" : null } }, { "Id" : "missing-created-at", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "599", "conditionText" : "extract('CA10Z1__createdAtUtc__c').isEmpty()", "runtimeError" : null } }, { "Id" : "age-boundary", "expectedResult" : { "status" : "INAPPLICABLE", "conditionIndex" : "699", "conditionText" : "extract('CA10Z1__createdAtUtc__c').withinLastDays(30)", "runtimeError" : null } }, { "Id" : "empty", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "799", "conditionText" : "CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT)", "runtimeError" : null } }, { "Id" : "only-disappeared-api", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "799", "conditionText" : "CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT)", "runtimeError" : null } }, { "Id" : "active-api", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "800", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10Z1__CaAzureApiManagementService__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__disappearanceTime__c" : new Date("2026-09-14T00:00:00Z"), "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Developer", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "gone" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "", "CA10Z1__skuName__c" : "Developer", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "missing-provisioning-state" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Updating", "CA10Z1__skuName__c" : "Developer", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "updating" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "missing-sku" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Consumption", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "consumption" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Developer", "Id" : "missing-created-at" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Developer", "CA10Z1__createdAtUtc__c" : new Date("2026-08-16T00:00:00Z"), "Id" : "age-boundary" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Developer", "CA10Z1__createdAtUtc__c" : new Date("2026-08-15T00:00:00Z"), "Id" : "empty" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Developer", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "only-disappeared-api" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__provisioningState__c" : "Succeeded", "CA10Z1__skuName__c" : "Standard", "CA10Z1__createdAtUtc__c" : new Date("2026-01-01T00:00:00Z"), "Id" : "active-api" } ]; """; CREATE TEMP FUNCTION mock_CA10Z1__CaAzureApiManagementApi__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__disappearanceTime__c" : new Date("2026-09-14T00:00:00Z"), "CA10Z1__service__c" : "only-disappeared-api", "Id" : "api-gone" }, { "context" : { "snapshotTime" : new Date("2026-09-15T00:00:00Z") }, "CA10Z1__service__c" : "active-api", "Id" : "api-active" } ]; """; CREATE TEMP FUNCTION process_CA10Z1__CaAzureApiManagementService__c( obj STRUCT< CA10Z1__disappearanceTime__c TIMESTAMP, CA10Z1__provisioningState__c STRING, CA10Z1__skuName__c STRING, CA10Z1__createdAtUtc__c TIMESTAMP, CA10Z1__Azure_API_Management_APIs__r ARRAY >>, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var IsEmptyLib = new function () { this.simpleIsEmpty = function(arg) { return arg == null; }; this.simpleIsNotEmpty = function(arg) { return arg != null; }; }(); 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)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var todayMinus30Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (-30 * 86400000); var todayPlus1Day = new Date(snapshotTime.toISOString().substr(0,10)+'T00:00:00.000Z').getTime() + (1 * 86400000); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From Azure [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c); if (obj.CA10Z1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function extract3() { if (!this.out) { this.out = obj.CA10Z1__provisioningState__c; } return this.out; }; references1.push('Provisioning State [obj.CA10Z1__provisioningState__c]: ' + obj.CA10Z1__provisioningState__c); if (TextLib.isEmpty(extract3.call(extract3))) { return {status: 'UNDETERMINED', conditionIndex: 199, conditionText: "extract('CA10Z1__provisioningState__c').isEmpty()", currentStateMessage: "Provisioning state is unavailable.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[2], conditionIndex:[200..299] function extract6() { if (!this.out) { this.out = obj.CA10Z1__provisioningState__c; } return this.out; }; if (TextLib.notEqual(extract6.call(extract6), 'Succeeded')) { return {status: 'INAPPLICABLE', conditionIndex: 299, conditionText: "extract('CA10Z1__provisioningState__c') != 'Succeeded'", currentStateMessage: "The API Management service is not successfully provisioned.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[3], conditionIndex:[300..399] function extract9() { if (!this.out) { this.out = obj.CA10Z1__skuName__c; } return this.out; }; references1.push('SKU: Name [obj.CA10Z1__skuName__c]: ' + obj.CA10Z1__skuName__c); if (TextLib.isEmpty(extract9.call(extract9))) { return {status: 'UNDETERMINED', conditionIndex: 399, conditionText: "extract('CA10Z1__skuName__c').isEmpty()", currentStateMessage: "SKU is unavailable.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[4], conditionIndex:[400..499] function extract12() { if (!this.out) { this.out = obj.CA10Z1__skuName__c; } return this.out; }; if (TextLib.equal(extract12.call(extract12), 'Consumption')) { return {status: 'INAPPLICABLE', conditionIndex: 499, conditionText: "extract('CA10Z1__skuName__c') == 'Consumption'", currentStateMessage: "The API Management service uses the Consumption tier.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[5], conditionIndex:[500..599] function extract15() { if (!this.out) { this.out = obj.CA10Z1__createdAtUtc__c; } return this.out; }; references1.push('Created At UTC [obj.CA10Z1__createdAtUtc__c]: ' + obj.CA10Z1__createdAtUtc__c); if (IsEmptyLib.simpleIsEmpty(extract15.call(extract15))) { return {status: 'UNDETERMINED', conditionIndex: 599, conditionText: "extract('CA10Z1__createdAtUtc__c').isEmpty()", currentStateMessage: "Creation time is unavailable.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[6], conditionIndex:[600..699] function extract18() { if (!this.out) { this.out = obj.CA10Z1__createdAtUtc__c; } return this.out; }; if (extract18.call(extract18) != null && extract18.call(extract18).getTime() >= todayMinus30Day && extract18.call(extract18).getTime() < todayPlus1Day) { return {status: 'INAPPLICABLE', conditionIndex: 699, conditionText: "extract('CA10Z1__createdAtUtc__c').withinLastDays(30)", currentStateMessage: "The API Management service is within its first 30 days.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } var count_CA10Z1__Azure_API_Management_APIs__r_COMPLIANT21 = 0; if (obj.CA10Z1__Azure_API_Management_APIs__r != null) { for (var i22 = 0; i22 < obj.CA10Z1__Azure_API_Management_APIs__r.length; i22++) { if (typeof(obj.CA10Z1__Azure_API_Management_APIs__r[i22].status) !== 'undefined') { if (obj.CA10Z1__Azure_API_Management_APIs__r[i22].status == 'COMPLIANT') { count_CA10Z1__Azure_API_Management_APIs__r_COMPLIANT21 += obj.CA10Z1__Azure_API_Management_APIs__r[i22].count; } } else { if (obj.CA10Z1__Azure_API_Management_APIs__r[i22].result.status == 'COMPLIANT') { count_CA10Z1__Azure_API_Management_APIs__r_COMPLIANT21 += 1; } } } } // condition[7], conditionIndex:[700..799] references1.push('Related list [CA10Z1__Azure_API_Management_APIs__r] ' + (count_CA10Z1__Azure_API_Management_APIs__r_COMPLIANT21 == 0 ? 'does not have' : 'has') + ' objects in COMPLIANT status'); if (count_CA10Z1__Azure_API_Management_APIs__r_COMPLIANT21 == 0) { return {status: 'INCOMPLIANT', conditionIndex: 799, conditionText: "CA10Z1__Azure_API_Management_APIs__r.hasNo(COMPLIANT)", currentStateMessage: "The non-Consumption API Management service has no active APIs.", currentStateReferences: references1.join('\n'), remediation: "Verify the API inventory in Azure, then remove the service if it is unused.", runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 800, conditionText: "otherwise", currentStateMessage: "The non-Consumption API Management service has at least one active API.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; CREATE TEMP FUNCTION process_CA10Z1__Azure_API_Management_APIs__r( obj STRUCT< CA10Z1__disappearanceTime__c TIMESTAMP, CA10Z1__service__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From Azure [CA10Z1__disappearanceTime__c]: ' + obj.CA10Z1__disappearanceTime__c); if (obj.CA10Z1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10Z1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } return {status: 'COMPLIANT', conditionIndex: 100, conditionText: "otherwise", currentStateMessage: "This API record is active in Cloudaware CMDB.", 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.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c, sObject.CA10Z1__provisioningState__c AS CA10Z1__provisioningState__c, sObject.CA10Z1__skuName__c AS CA10Z1__skuName__c, sObject.CA10Z1__createdAtUtc__c AS CA10Z1__createdAtUtc__c, `CA10Z1__Azure_API_Management_APIs__r`.arr AS CA10Z1__Azure_API_Management_APIs__r, sObject.Id AS Id, process_CA10Z1__CaAzureApiManagementService__c( STRUCT( sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c, sObject.CA10Z1__provisioningState__c AS CA10Z1__provisioningState__c, sObject.CA10Z1__skuName__c AS CA10Z1__skuName__c, sObject.CA10Z1__createdAtUtc__c AS CA10Z1__createdAtUtc__c, `CA10Z1__Azure_API_Management_APIs__r`.arr AS CA10Z1__Azure_API_Management_APIs__r, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10Z1__CaAzureApiManagementService__c()) AS sObject LEFT JOIN ( SELECT sObject.CA10Z1__service__c, ARRAY_AGG( STRUCT( sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c, sObject.CA10Z1__service__c AS CA10Z1__service__c, sObject.Id AS Id, process_CA10Z1__Azure_API_Management_APIs__r( STRUCT( sObject.CA10Z1__disappearanceTime__c AS CA10Z1__disappearanceTime__c, sObject.CA10Z1__service__c AS CA10Z1__service__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result ) ) AS arr FROM UNNEST(mock_CA10Z1__CaAzureApiManagementApi__c()) AS sObject GROUP BY sObject.CA10Z1__service__c ) AS `CA10Z1__Azure_API_Management_APIs__r` ON sObject.Id = `CA10Z1__Azure_API_Management_APIs__r`.CA10Z1__service__c ) sObject ON sObject.Id = expectedResult.Id;