Count a blueprint's entities matching a search query
POST/v1/blueprints/:blueprint_identifier/entities/search/count
This route allows you to count your software catalog's entities for a specific blueprint, based on a given set of rules.
Pass an empty body (or omit query) to count all entities visible to the caller.
To learn more about entities, check out the entity documentation.
For more details about Port's search mechanism, rules, and operators - see the search & query documentation.
Request
Parameters (JSON)
{
"parameters": [
{
"schema": {
"type": "string",
"minLength": 1
},
"in": "path",
"name": "blueprint_identifier",
"required": true,
"description": "The identifier of the blueprint whose entities you want to search."
}
]
}Request body schema (JSON)
{
"title": "Body",
"body": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"query": {
"title": "Entities query",
"type": "object",
"properties": {
"combinator": {
"enum": [
"and",
"or"
]
},
"rules": {
"type": "array",
"items": {
"anyOf": [
{
"type": "object",
"title": "Date Rule",
"properties": {
"property": {
"title": "Contexted property",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
},
"operator": {
"enum": [
"between",
"notBetween",
"="
]
},
"value": {
"type": "object",
"oneOf": [
{
"type": "object",
"title": "Date Range",
"properties": {
"from": {
"type": "string",
"format": "date-time"
},
"to": {
"type": "string",
"format": "date-time"
}
},
"required": [
"from",
"to"
]
},
{
"type": "object",
"title": "Date Preset",
"properties": {
"preset": {
"type": "string",
"enum": [
"today",
"tomorrow",
"yesterday",
"lastDay",
"lastWeek",
"last2Weeks",
"lastMonth",
"last3Months",
"last6Months",
"last12Months",
"last2Years",
"last3Years",
"nextDay",
"nextWeek",
"next2Weeks",
"nextMonth",
"next3Months",
"next6Months",
"next12Months"
]
}
},
"required": [
"preset"
]
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
}
},
"required": [
"property",
"operator",
"value"
],
"additionalProperties": false
},
{
"type": "object",
"title": "Empty Rule",
"oneOf": [
{
"title": "Property empty rule",
"properties": {
"operator": {
"enum": [
"isEmpty",
"isNotEmpty"
]
},
"property": {
"type": "string"
}
},
"required": [
"operator",
"property"
],
"additionalProperties": false
},
{
"title": "Relation empty rule",
"properties": {
"operator": {
"enum": [
"isEmpty",
"isNotEmpty"
]
},
"targetProperty": {
"type": "string",
"enum": [
"$title",
"$identifier"
]
},
"relation": {
"type": "string"
}
},
"required": [
"operator",
"relation"
],
"additionalProperties": false
},
{
"title": "Scorecard empty rule",
"properties": {
"operator": {
"enum": [
"isEmpty",
"isNotEmpty"
]
},
"scorecardRule": {
"type": "string"
},
"scorecard": {
"type": "string"
}
},
"required": [
"operator",
"scorecard"
],
"additionalProperties": false
}
]
},
{
"type": "object",
"title": "Expired Rule",
"oneOf": [
{
"type": "object",
"title": "Expired Rule",
"properties": {
"operator": {
"enum": [
"isExpired",
"isNotExpired"
]
},
"property": {
"type": "string"
}
},
"required": [
"operator",
"property"
],
"additionalProperties": false
}
]
},
{
"type": "object",
"title": "Number Rule",
"properties": {
"property": {
"title": "Contexted property",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
},
"operator": {
"enum": [
">",
">=",
"<",
"<="
]
},
"value": {
"anyOf": [
{
"type": "number",
"title": "number"
},
{
"type": "string",
"format": "date-time",
"title": "date-time"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
}
},
"required": [
"property",
"operator",
"value"
],
"additionalProperties": false
},
{
"type": "object",
"title": "String Rule",
"oneOf": [
{
"type": "object",
"title": "Property string rule",
"properties": {
"property": {
"title": "Contexted property",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
},
"operator": {
"enum": [
"=",
"!=",
"containsAny",
"contains",
"doesNotContains",
"beginsWith",
"doesNotBeginsWith",
"endsWith",
"doesNotEndsWith",
"in",
"notIn"
]
},
"value": {
"anyOf": [
{
"type": "null"
},
{
"type": "string",
"title": "string"
},
{
"type": "number",
"title": "number"
},
{
"type": "boolean",
"title": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "number"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "boolean"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "string",
"format": "date-time"
},
"title": "array"
},
{
"type": "string",
"format": "date-time",
"title": "date-time"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
}
},
"additionalProperties": false,
"required": [
"property",
"operator",
"value"
]
},
{
"type": "object",
"title": "Relation string rule",
"properties": {
"relation": {
"type": "string"
},
"targetProperty": {
"type": "string",
"enum": [
"$title",
"$identifier"
]
},
"operator": {
"enum": [
"=",
"!=",
"containsAny",
"contains",
"doesNotContains",
"beginsWith",
"doesNotBeginsWith",
"endsWith",
"doesNotEndsWith",
"in",
"notIn"
]
},
"value": {
"anyOf": [
{
"type": "null"
},
{
"type": "string",
"title": "string"
},
{
"type": "number",
"title": "number"
},
{
"type": "boolean",
"title": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "number"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "boolean"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "string",
"format": "date-time"
},
"title": "array"
},
{
"type": "string",
"format": "date-time",
"title": "date-time"
}
]
}
},
"additionalProperties": false,
"required": [
"relation",
"operator",
"value"
]
},
{
"type": "object",
"title": "Scorecard string rule",
"properties": {
"scorecard": {
"type": "string"
},
"scorecardRule": {
"type": "string"
},
"operator": {
"enum": [
"=",
"!=",
"containsAny",
"contains",
"doesNotContains",
"beginsWith",
"doesNotBeginsWith",
"endsWith",
"doesNotEndsWith",
"in",
"notIn"
]
},
"value": {
"anyOf": [
{
"type": "null"
},
{
"type": "string",
"title": "string"
},
{
"type": "number",
"title": "number"
},
{
"type": "boolean",
"title": "boolean"
},
{
"type": "array",
"items": {
"type": "string"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "number"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "boolean"
},
"title": "array"
},
{
"type": "array",
"items": {
"type": "string",
"format": "date-time"
},
"title": "array"
},
{
"type": "string",
"format": "date-time",
"title": "date-time"
}
]
}
},
"additionalProperties": false,
"required": [
"scorecard",
"operator",
"value"
]
}
]
},
{
"type": "object",
"title": "Relation Rule",
"properties": {
"operator": {
"enum": [
"relatedTo"
]
},
"blueprint": {
"type": "string"
},
"value": {
"anyOf": [
{
"type": "string",
"title": "string"
},
{
"type": "array",
"items": {
"type": "string"
},
"title": "array"
}
]
},
"direction": {
"enum": [
"upstream",
"downstream"
]
},
"required": {
"type": "boolean"
}
},
"additionalProperties": false,
"required": [
"operator",
"value",
"blueprint"
]
},
{
"type": "object",
"title": "All properties search filter",
"properties": {
"operator": {
"enum": [
"allPropertiesSearch"
]
},
"value": {
"type": "string",
"minLength": 1
},
"properties": {
"type": "array",
"items": {
"type": "string"
},
"minItems": 1
}
},
"required": [
"operator",
"value"
],
"additionalProperties": false
},
{
"type": "object",
"title": "Property schema rule",
"properties": {
"propertySchema": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"format": {
"type": "string"
},
"items": {
"type": "object",
"properties": {
"type": {
"type": "string"
},
"format": {
"type": "string"
}
},
"required": [
"type"
]
}
},
"required": [
"type"
],
"additionalProperties": false
},
"operator": {
"enum": [
"=",
"!=",
"contains"
]
},
"value": {
"anyOf": [
{
"type": "null",
"title": "null"
},
{
"type": "string",
"title": "string"
},
{
"type": "number",
"title": "number"
},
{
"type": "boolean",
"title": "boolean"
}
]
}
},
"required": [
"operator",
"propertySchema"
],
"additionalProperties": false
},
{
"type": "object",
"title": "matchAny Rule",
"anyOf": [
{
"type": "object",
"title": "Property matchAny rule",
"properties": {
"property": {
"oneOf": [
{
"type": "object",
"title": "Path filter property",
"properties": {
"path": {
"type": "array",
"minItems": 1,
"items": {
"anyOf": [
{
"type": "string",
"title": "Relation identifier"
},
{
"type": "object",
"title": "Relation with max hops",
"properties": {
"relation": {
"type": "string"
},
"maxHops": {
"type": "number",
"minimum": 1,
"maximum": 15
}
}
}
]
}
},
"fromBlueprint": {
"type": "string"
}
},
"required": [
"path"
],
"additionalProperties": false
},
{
"title": "Contexted property",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
}
]
},
"operator": {
"type": "string",
"enum": [
"matchAny"
]
},
"value": {
"anyOf": [
{
"type": "array",
"items": {
"type": "string"
}
},
{
"title": "Contexted property",
"oneOf": [
{
"type": "string"
},
{
"type": "object",
"title": "User-context field",
"properties": {
"property": {
"type": "string"
},
"context": {
"type": "string",
"enum": [
"user",
"userTeams"
]
}
},
"required": [
"property",
"context"
]
}
]
}
]
}
},
"required": [
"property",
"operator",
"value"
],
"additionalProperties": false
}
]
},
{
"allOf": [
"circular(Entities query)",
{
"title": "Nested query"
}
]
}
]
}
}
},
"required": [
"combinator",
"rules"
],
"additionalProperties": false
}
},
"additionalProperties": false,
"example": {
"query": {
"combinator": "and",
"rules": [
{
"property": "$blueprint",
"operator": "=",
"value": "service"
},
{
"property": "environment",
"operator": "=",
"value": "production"
}
]
}
}
}
}
}
}
}Responses
- 200
- 401
- 404
- 413
- 422
Retrieved successfully.
Default Response
A resource with the provided identifier was not found
Request body is too large (limit is 1MiB)
The json provided does not match the route's schema
Responses (JSON)
{
"responses": {
"200": {
"description": "Retrieved successfully.",
"content": {
"application/json": {
"schema": {
"description": "Retrieved successfully.",
"properties": {
"ok": {
"enum": [
true
]
},
"count": {
"type": "number"
}
},
"required": [
"ok"
],
"additionalProperties": false
}
}
}
},
"401": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error"
],
"additionalProperties": false
}
}
}
},
"404": {
"description": "A resource with the provided identifier was not found",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error",
"message"
],
"additionalProperties": false,
"description": "A resource with the provided identifier was not found"
}
}
}
},
"413": {
"description": "Request body is too large (limit is 1MiB)",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error"
],
"additionalProperties": false,
"description": "Request body is too large (limit is 1MiB)"
}
}
}
},
"422": {
"description": "The json provided does not match the route's schema",
"content": {
"application/json": {
"schema": {
"properties": {
"ok": {
"const": false
},
"error": {
"type": "string"
},
"message": {
"type": "string"
}
},
"required": [
"ok",
"error",
"message"
],
"additionalProperties": false,
"description": "The json provided does not match the route's schema"
}
}
}
}
}
}