---
title: Knowledge APIs
tags: Documentation, APIdoc
description: Vertical Agnostic APIs for Knowledge Repository
---
# Repository | Knowledge APIs
*Vertical Agnostic APIs for Knowledge Repository*
[TOC]
# Type of Knowledge APIs
**Knowledge Schema APIs** – manage meta-data about the knowledge repository.
**Knowledge Identity APIs** – manages the mapping between business and internal entity id’s.
Brain Identity Service is the one who takes care of maintaining the BrainID across the system hence we decided to keep all the identity-related responsibilities with Brain Identity Service itself. We will not have a Knowledge Identity as a microservice.
**Knowledge Name APIs** – manages the entity identity and name mapping across languages.
Brain Name Service is the one who takes care of maintaining the names across the system hence we decided to keep all the name-related responsibilities with Brain Name Service itself. We will not have a Knowledge Name as a microservice.
**Knowledge Nugget APIs** – manage the data within the knowledge repository
# Overall Gateway Architecture

---
```protobuf=
// BrainRepositoryService
service BrainRepositoryService {
rpc serve(BrainRepositoryServiceRequest) returns (BrainRepositoryServiceResponse){}
}
message BrainRepositoryServiceRequest {
oneof request{
KnowledgeServiceRequest knowledge_service_request = 1;
FeatureServiceRequest feature_service_request = 2;
ModelServiceRequest model_service_request = 3;
}
}
message BrainRepositoryServiceResponse {
oneof response{
KnowledgeServiceResponse knowledge_service_response = 1;
FeatureServiceResponse feature_service_response = 2;
ModelServiceResponse model_service_response = 3;
}
}
service KnowledgeService {
rpc serve(KnowledgeServiceRequest) returns (KnowledgeServiceResponse) {}
}
message KnowledgeServiceRequest {
oneof request{
KnowledgeSchemaServiceRequest knowledge_schema_request = 1;
KnowledgeNuggetServiceRequest knowledge_nugget_request = 2;
}
}
message KnowledgeServiceResponse {
oneof request{
KnowledgeSchemaServiceResponse knowledge_schema_response = 1;
KnowledgeNuggetServiceResponse knowledge_nugget_response = 2;
}
}
message KnowledgeSchemaServiceRequest {
// Note: covered in KnowledgeSchemaService section
}
```
# Knowledge Schema APIs
---
```protobuf=
service KnowledgeSchemaService {
rpc serve(KnowledgeSchemaServiceRequest) returns (KnowledgeSchemaServiceResponse) {}
}
message KnowledgeSchemaServiceRequest {
oneof request{
AddDomainRequest add_domain_request = 1;
GetAllDomainsRequest get_all_domains_request = 2;
HasDomainRequest has_domain_request = 3;
RenameDomainRequest rename_domain_request = 4;
DeleteDomainRequest delete_domain_request = 5;
AddEntityRequest add_entity_request = 6;
MoveEntityRequest move_entity_request = 7;
GetAllEntitiesRequest get_all_entities_request = 8;
HasEntityRequest has_entity_request = 9;
RenameEntityRequest rename_entity_request = 10;
DeleteEntityRequest delete_entity_request = 11;
AddAttributeRequest add_attribute_request = 12;
GetAllAttributesRequest get_all_attributes_request = 13;
GetAttributeQuantityRequest add_attribute_quantity_request = 14;
HasAttributeRequest has_attribute_request = 15;
RenameAttributeRequest rename_attribute_request = 16;
DeleteAttributeRequest delete_attribute_request = 17;
AddAttributeQualifierRequest add_attribute_qualifier_request = 19;
GetAllAttributeQualifierRequest get_all_attribute_qualifier_request = 20;
HasAttributeQualifierRequest has_attribute_qualifier_request = 21;
DeleteAttributeQualifierRequest delete_attribute_qualifier_request = 22;
RenameQualifierInAttributeRequest rename_qualifier_in_attribute_request = 23;
GetAttributeQualifierQuantityRequest get_attribute_qualifier_quantity_request = 24;
AddPredicateRequest add_predicate_request = 25;
GetPredicatesRequest add_predicates_request = 26;
HasPredicateRequest has_predicate_request = 27;
RenamePredicateRequest rename_predicate_request = 28;
DeletePredicateRequest delete_predicate_request = 29;
AddQualifiersToPredicateRequest add_qualifiers_to_predicate_request = 29;
AddPredicateQualifierRequest add_predicate_qualifier_request = 30;
GetAllPredicateQualifiersRequest get_all_predicate_qualifiers_request = 31;
HasPredicateQualifierRequest has_predicate_qualifier_request = 32;
GetAllAttributesByQuantityRequest add_predicate_request = 33;
RenameQualifierInPredicateRequest rename_qualifier_in_predicate_request = 34;
DeletePredicateQualifierRequest delete_predicate_qualifier_request = 35;
AddAttributeGroupRequest add_attribute_group_request = 36;
AddAttributeToAttributeGroupRequest add_attribute_to_attribute_group_request = 37;
HasAttributeGroupRequest has_attribute_group_request = 38;
RenameAttributeGroupRequest rename_attribute_group_request = 39;
DeleteAttributeFromAttributeGroupRequest delete_attribute_from_attribute_group_request = 40;
DeleteAttributeGroupRequest delete_attribute_group_request = 41;
}
}
message KnowledgeSchemaServiceResponse {
oneof response{
AddDomainResponse add_domain_response = 1;
GetAllDomainsResponse get_all_domains_response = 2;
HasDomainResponse has_domain_response = 3;
RenameDomainResponse rename_domain_response = 4;
DeleteDomainResponse delete_domain_response = 5;
AddEntityResponse add_entity_response = 6;
MoveEntityResponse move_entity_response = 7;
GetAllEntitiesResponse get_all_entities_response = 8;
HasEntityResponse has_entity_response = 9;
RenameEntityResponse rename_entity_response = 10;
DeleteEntityResponse delete_entity_response = 11;
AddAttributeResponse add_attribute_response = 12;
GetAllAttributesResponse get_all_attributes_response = 13;
GetAttributeQuantityResponse add_attribute_quantity_response = 14;
HasAttributeResponse has_attribute_response = 15;
RenameAttributeResponse rename_attribute_response = 16;
DeleteAttributeResponse delete_attribute_response = 17;
AddAttributeQualifierResponse add_attribute_qualifier_response = 18;
GetAllAttributeQualifierResponse get_all_attribute_qualifier_response = 19;
HasAttributeQualifierResponse has_attribute_qualifier_response = 20;
DeleteAttributeQualifierResponse delete_attribute_qualifier_response = 21;
RenameQualifierInAttributeResponse rename_qualifier_in_attribute_response = 22;
GetAttributeQualifierQuantityResponse get_attribute_qualifier_quantity_response = 23;
AddPredicateResponse add_predicate_response = 24;
GetPredicatesResponse add_predicates_response = 25;
HasPredicateResponse has_predicate_response = 26;
RenamePredicateResponse rename_predicate_response = 27;
DeletePredicateResponse delete_predicate_response = 28;
AddQualifiersToPredicateResponse add_qualifiers_to_predicate_response = 29;
AddPredicateQualifierResponse add_predicate_qualifier_response = 30;
GetAllPredicateQualifiersResponse get_all_predicate_qualifiers_response = 31;
HasPredicateQualifierResponse has_predicate_qualifier_response = 32;
GetAllAttributesByQuantityResponse add_predicate_response = 33;
RenameQualifierInPredicateResponse rename_qualifier_in_predicate_response = 34;
DeletePredicateQualifierResponse delete_predicate_qualifier_response = 35;
AddAttributeGroupResponse add_attribute_group_response = 36;
AddAttributeToAttributeGroupResponse add_attribute_to_attribute_group_response = 37;
HasAttributeGroupResponse has_attribute_group_response = 38;
RenameAttributeGroupResponse rename_attribute_group_response = 39;
DeleteAttributeFromAttributeGroupResponse delete_attribute_from_attribute_group_response = 40;
DeleteAttributeGroupResponse delete_attribute_group_response = 41;
}
}
```
## Domain Schema APIs
### Add a new Domain
|**API Path**|/repository/knowledge/schema/domain|
| -: | :- |
|**API Name**|**addDomain**|
|**Description**|Adds a new Domain to the Repository|
|**Input**|Adds a new Domain to the Repository|
|**Output**|Status (all ok or one of the error codes with parameters) |
|**Errors**|***errorAlreadyExist***({domain: domainName})**errorFormatMissmatch**({domain: domainName})|
|**Example**|**addDomain**(common)|
------
```protobuf=
// Adds a new Domain to the Repository
message AddDomainRequest {
string domain_name = 1; // Healthcare
}
message AddDomainResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get all Domains
|**API Path**|/repository/knowledge/schema/domain|
| -: | :- |
|**API Name**|**getAllDomains**|
|**Description**|Get the set of all domains in the repository|
|**Input**|None|
|**Output**|domainSet (set<domainName>)|
|**Errors**|*none*|
|**Example**|domainSet** = **getAllDomains** ()|
------
```protobuf=
// Get the set of all domains in the repository
message GetAllDomainsRequest {
}
message GetAllDomainsResponse {
repeated string domain_name = 1; // Common, Healthcare, Agriculture, Telecom
BrainStatus status = 2; //Brain status response
}
```
### Check if a Domain exists
|**API Path**|/repository/knowledge/schema/domain|
| -: | :- |
|**API Name**|**hasDomain**|
|**Description**|Checks whether a domain is already present in the repository or not.|
|**Input**|domainName (string)|
|**Output**|Boolean (true domainName is present, else absent)|
|**Errors**|*none*|
|**Example**|**hasDomain**(common)|
---
```protobuf=
//Checks whether a domain is already present in the repository or not.
Message HasDomainRequest {
string domain_name = 1; //Common
}
message HasDomainResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Rename a Domain
|**API Path**|/repository/knowledge/schema/domain|
| -: | :- |
|**API Name**|**renameDomain**|
|**Description**|Remains a domain from one name to another|
|**Input**|oldDomainName (string)newDomainName (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: oldDomainName})***errorAlreadyExists***({domain: newDomainName})|
|**Example**|**renameDomain**(common, general)|
---
```protobuf=
//Renames a domain from one name to another
message RenameDomainRequest {
string old_domain_name = 1; //Common
string new_domain_name = 2; //General
}
message RenameDomainResponse {
BrainStatus status = 1; //Brain status response
}
```
### Delete a Domain
|**API Path**|/repository/knowledge/schema/domain|
| -: | :- |
|**API Name**|**deleteDomain**|
|**Description**|Deletes a domain and all the related components from the knowledge repository|
|**Input**|domainName (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})|
|**Example**|**deleteDomain**(common)|
---
```protobuf=
//Deletes a domain and all the related components from the knowledge repository
message DeleteDomainRequest {
string domain_name = 1; //Healthcare
}
message DeleteDomainResponse {
BrainStatus status = 1; //Brain status response
}
```
## Entity Schema APIs
### Add a new Entity in a Domain
|**API Path**|/repository/knowledge/schema/entity|
| -: | :- |
|**API Name**|**addEntity**|
|**Description**|Add one or more entity types to an existing domain in the repository|
|**Inputs**|domainName (string)entityTypeSet (set<string>)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorAlreadyExist***({entity: entityType})|
|**Example**|**addEntity**(common, {country, sate, city, river, person, monument})|
---
```protobuf=
///Add one or more entity types to an existing domain in the repository
message AddEntityRequest {
string domain_name = 1; //Common
repeated string entity_type = 2; //person
}
message AddEntityResponse {
BrainStatus status = 1; //Brain status response
}
```
### Move an Entity to another Domain
|**API Path**|/repository/knowledge/schema/entity|
| -: | :- |
|**API Name**|**moveEntity**|
|**Description**|Moves an existing entity to a another domain|
|**Inputs**|entityType(String)oldDomainName (string)newDomainName (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: oldDomainName })***errorDoesNotExist***({domain: oldDomainName, entity: entityType })<br>***errorDoesNotExist***({domain: newDomainName })***errorAlreadyExist***({entity: entityType })|
|**Example**|**moveEntity** (person, hrplatform, common)|
---
```protobuf=
//Moves an existing entity to another domain
message MoveEntityRequest {
string entity_type = 1; //soil
string old_domain_name = 2; //Common
string new_domain_name = 3; //Agriculture
}
message MoveEntityResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get all Entities in a Domain
|**API Path**|/repository/knowledge/schema/entity|
| -: | :- |
|**API Name**|**getAllEntities**|
|**Description**|Return a list of all entity types in a domain|
|**Inputs**|domainName (string)|
|**Output**|entityTypeSet (set<string>)|
|**Errors**|***errorDoesNotExist***({domain: domainName})|
|**Example**|**getAllEntities** (common)|
---
```protobuf=
//Return a list of all entity types in a domain
message GetAllEntitiesRequest {
string domain_name = 1; //Common
}
message GetAllEntitiesResponse {
repeated string entity_type = 1; //person, country
BrainStatus status = 2; //Brain status response
}
```
### Check if an Entity exists in a Domain
|**API Path**|/repository/knowledge/schema/entity|
| -: | :- |
|**API Name**|**hasEntity**|
|**Description**|Returns true if entity type exists in the domain else false|
|**Inputs**|domainName (string)entityType (string)|
|**Output**|Boolean|
|**Errors**|***errorDoesNotExist***({domain: domainName})|
|**Example**|**hasEntity**(common, country)|
---
```protobuf=
//Returns true if entity type exists in the domain else false
message HasEntityRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
}
message HasEntityResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Rename an Entity in a Domain
|**API Path**|/repository/knowledge/schema/entity|
| -: | :- |
|**API Name**|**renameEntity**|
|**Description**|Renames the entity from an old name to a new name within the domain|
|**Inputs**|domainName (string)oldEntityType (string)newEntityType (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: oldEntityType})***errorAlreadyExist***({domain: domainName, entity: newEntityType})|
|**Example**|**renameEntity** (common, country, nation)|
---
```protobuf=
//Renames the entity from an old name to a new name within the domain
message RenameEntityRequest {
string domain_name = 1; //common
string old_entity_type = 2; //country
string new_entity_type = 3; //nation
}
message RenameEntityResponse {
BrainStatus status = 1; //Brain status response
}
```
### Delete an Entity from a Domain
|**API Path**|/repository/knowledge/schema/entity|
| -: | :- |
|**API Name**|**deleteEntity**|
|**Description**|Delete an entity in a Domain|
|**Inputs**|domainName (string)entityType (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})|
|**Example**|**deleteEntity**(common, country)|
---
```protobuf=
//Delete an entity in a Domain
message DeleteEntityRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
}
message DeleteEntityResponse {
BrainStatus status = 1; //Brain status response
}
```
## Attribute Schema APIs
### Add an Attribute of a Quantity type to an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute|
| -: | :- |
|**API Name**|**addAttribute**|
|**Description**|Add an attribute of a certain quantity type to an entity in a domain|
|**Inputs**|domainName (string)entityType (string)attributeName (string)quantityType (string)quantityUnit (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorAlreadyExists***({domain: domainName, entity: entityType, attribute: attributeName})|
|**Example**|**addAttribute**(common, country, area, /quantity/area, /unit/area/sqkm)|
---
```protobuf=
//Add an attribute of a certain quantity type to an entity in a domain
message AddAttributeRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
string attribute_name = 3; // weight
string quantity_type = 4; // quantity/weight
string quantity_unit = 5; // unit/weight/kilogram
}
message AddAttributeResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get all Attributes of an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute|
| -: | :- |
|**API Name**|**getAllAttributes**|
|**Description**|Return a set of all attributes of an entity in a domain|
|**Inputs**|domainName (string)entityType (string)|
|**Output**|attributeSet (set<attributeName>)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})|
|**Example**|{/attribute/common/coutry/area, /attribute/common/coutry/, ..} **= getAllAttributes**(common, country)|
---
```protobuf=
//Return a set of all attributes of an entity in a domain
message GetAllAttributesRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
}
message GetAllAttributesResponse {
repeated string attributes = 1; //population, gdp
BrainStatus status = 2; //Brain status response
}
```
### Get Quantity type of an Attribute of an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute|
| -: | :- |
|**API Name**|**getAttributeQuantity**|
|**Description**|Return the quantity type of an attribute of an entity in the domain|
|**Inputs**|domainName (string)entityType (string)attributeName (string)|
|**Output**|(quantityType (string), quantityUnit (string))|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})|
|**Example**|/quantity/area = **getAttributeQuantity**(common, country, area)|
---
```protobuf=
//Get Quantity type of an Attribute of an Entity in a Domain
message GetAttributeQuantityRequest {
string domain_name = 1; //common
string entity_type = 2; //country
string attribute_name = 3; //area
}
message GetAttributeQuantityResponse {
string quantity_type = 1; // quantity/area
BrainStatus status = 2; //Brain status response
}
```
### Get all Attributes of an Entity in a Domain that are of a certain Quantity type
|**API Path**|/repository/knowledge/schema/attribute|
| -: | :- |
|**API Name**|**getAllAttributesByQuantity**|
|**Description**|Return attribute names of all attributes of an entity that have a certain quantity type|
|**Inputs**|domainName (string)entityType (string)quantityType (string)|
|**Output**|AttributeSet (set<attributeName>)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({quantity: quantityType})|
|**Example**|{total\_area, urban\_area} = **getAllAttributesByQuantity** (common, country, /quantity/area)|
---
```protobuf=
//Get all attributes which have a given quantity
message GetAllAttributesByQuantityRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
string quantity_type = 3; // /quantity/area
}
message GetAllAttributesByQuantityResponse {
repeated string attributes = 1; //total_area, urban_area
BrainStatus status = 2; //Brain status response
}
```
### Check if an Attribute exists for an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute|
| -: | :- |
|**API Name**|**hasAttribute**|
|**Description**|Returns true if attributeName is a valid attribute for an entity|
|**Inputs**|domainName (string)entityType (string)attributeName (string)|
|**Output**|Boolean|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})|
|**Example**|Bool yes\_no = **hasAttribute**(common, country, area)|
---
```protobuf=
//Returns true if attributeName is a valid attribute for an entity
message HasAttributeRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
string attribute_name = 3; //gdp
}
message HasAttributeResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Rename an Attribute of an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute|
| -: | :- |
|**API Name**|**renameAttribute**|
|**Description**|Returns true if attributeName is a valid attribute for an entity|
|**Inputs**|domainName (string)entityType (string)oldAttributeName (string)newAttributeName (string)|
|**Output**|Status (or or Error Code)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: oldAttributeN..})***errorAlreadyExists***({domain: domainName, entity: entityType, attribute: newAttributeN..})|
|**Example**|**renameAttribute**(common, country, area, total\_area)|
---
```protobuf=
//Renames attribute for an entity
message RenameAttributeRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
string old_attribute_name = 3; // area
string new_attribute_name = 4; // total_area
}
message RenameAttributeResponse {
BrainStatus status = 1; //Brain status response
}
```
### Delete an Attribute of an Entity in a Domain
|**API Path**|/repository/knowledge/schema|
| -: | :- |
|**API Name**|**deleteAttribute**|
|**Description**|Deletes an attribute of an attributeName from an Entity in a domain|
|**Inputs**|domainName (string)entityType (string)attributeName (string)|
|**Output**|Status (or or Error Code)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})|
|**Example**|**deleteAttribute** (common, country, area)|
---
```protobuf=
//Deletes an attribute of an attributeName from an Entity in a domain
message DeleteAttributeRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
string attribute_name = 3; //weight
}
message DeleteAttributeResponse {
BrainStatus status = 1; //Brain status response
}
```
## Attribute Qualifier Schema APIs
- There are two types of attributes: absolute, qualified.
- an absolute attribute does not have any additional qualifiers
- A qualified attribute (e.g. gdp of a country) can have one or more qualifiers (e.g. year)
- Each attribute qualifier has a unique name (within the attribute)
- Each attribute qualifier is associated with a specific quantity
### Add a new Qualifier to an Attribute to an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute/qualifier|
| -: | :- |
|**API Name**|**addAttributeQualifier**|
|**Description**|Add a qualifier and its quantity type to an attribute of an entity in a domain|
|**Inputs**|domainName (string)entityType (string) attributeName (string) qualifierName (string) quantityType (string) |
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})***errorAlreadyExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName, qualifier: qualifierName})|
|**Example**|**addAttributeQualifier**(common, country, gdp, year, QuantityYear)|
---
```protobuf=
//Add a qualifier and its quantity type to an attribute of an entity in a domain
/
There are two types of attributes: absolute, qualified.
An absolute attribute does not have any additional qualifiers
A qualified attribute (e.g. gdp of a country) can have one or more qualifiers (e.g. year)
Each attribute qualifier has a unique name (within the attribute)
Each attribute qualifier is associated with a specific quantity
**/
message AddAttributeQualifierRequest {
string domain_name = 1; //Common
string entity_type = 2; // country
string attribute_name = 3; // gdp
string qualifier_name = 4; //year
string quantity_type = 5; //QuantityYear
}
message AddAttributeQualifierResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get all Qualifiers of an Attribute of an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute/qualifier|
| -: | :- |
|**API Name**|**getAllAttributeQualifiers**|
|**Description**|Returns all qualifiers associated with an attribute of an entity in a domain|
|**Inputs**|domainName (string)entityType (string) attributeName (string) |
|**Output**|qualifierMap(map<qualifierName, quantityName>)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})|
|**Example**|{/qualifier/year, /qualifier/quarter} = **getAllAttributeQualifiers** (common, country, gdp)|
---
```protobuf=
//Returns all qualifiers associated with an attribute of an entity in a domain
message GetAllAttributeQualifierRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
string attribute_name = 3; //gdp
}
message GetAllAttributeQualifierResponse {
map<string, string> qualifier_map = 1; // {/qualifier/year, /qualifier/quarter}
BrainStatus status = 2; //Brain status response
}
```
### Check if a Qualifier exists in anAttribute for an Entity in a Domain
|**API Path**|/repository/knowledge/schema/ attribute/qualifier|
| -: | :- |
|**API Name**|**hasAttributeQualifier**|
|**Description**|Returns true if qualifier is present in the attribute|
|**Inputs**|domainName (string)entityType (string) attributeName (string) qualifierName (string)|
|**Output**|Boolean |
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})|
|**Example**|Bool yes\_no = **hasAttributeQualifier**(common, country, gdp, year)|
---
```protobuf=
//Returns true if qualifier is present in the attribute
message HasAttributeQualifierRequest {
string domain_name = 1; //Common
string entity_type = 2; //country
string attribute_name = 3; //gdp
string qualifier_name = 4; //year
}
message HasAttributeQualifierResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Delete a Qualifier from an Attribute of an Entity in a Domain
|**API Path**|/repository/knowledge/schema/ attribute/qualifier|
| -: | :- |
|**API Name**|**deleteAttributeQualifier**|
|**Description**|Deletes a qualifier from an attribute of an entity in a domain|
|**Inputs**|domainName (string)entityType (string) attributeName (string) qualiierName (string)|
|**Output**|Status (ok or error code) |
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName}, qualifier: qualifierName)|
|**Example**|**deleteAttributeQualifierout** (common, country, gdp)|
---
```protobuf=
//Deletes a qualifier from an attribute of an entity in a domain
message DeleteAttributeQualifierRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
string attribute_name = 3; //salary
string qualifier_name = 4; //year
}
message DeleteAttributeQualifierResponse {
BrainStatus status = 1; //Brain status response
}
```
### Rename a Qualifier of an Attribute of an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute/qualifier|
| -: | :- |
|**API Name**|**renameQualifierInAttribute**|
|**Description**|Renames a qualifier with a different name for an attribute of an entity in a domain|
|**Inputs**|domainName (string)entityType (string) attributeName (string) oldQualifierName (string)newQualifierName (string)|
|**Output**|Status (ok or error code) |
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName}, qualifier: oldQualifierName)***errorAlreadyExists***({domain: domainName, entity: entityType, ' 'attribute: attributeName}, qualifier: newQualifierName)|
|**Example**|**renameQualifierInAttribute** (common, country, gdp, GDP)|
---
```protobuf=
//Renames a qualifier with a different name for an attribute of an entity in a domain
message RenameQualifierInAttributeRequest {
string domain_name = 1; //common
string entity_type = 2; //country
string attribute_name = 3; //gdp
string old_qualifier_name = 4; //year
string new_qualifier_name = 5; //yearly
}
message RenameQualifierInAttributeResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get the Quantity type of a Qualifier of an Attribute
|**API Path**|/repository/knowledge/schema/attribute/qualifier|
| -: | :- |
|**API Name**|**getAttributeQualifierQuantity**|
|**Description**|Return the quantity type of an predicate qualifier in the domain|
|**Inputs**|domainName (string)entityType (string) attributeName (string) qualifierName (string)|
|**Output**|(quantityType (string), quantityUnit (string))|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: attributeName})***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName}, qualifier: qualifierName)|
|**Example**|/quantity/date = **getAttributeQualifierQuantity** (common, country, gdp, year)|
---
```protobuf=
//Return the quantity type of an predicate qualifier in the domain
message GetAttributeQualifierQuantityRequest {
string domain_name = 1; //common
string entity_type = 2; //country
string attribute_name = 3; //gdp
string qualifier_name = 4; //year
}
message GetAttributeQualifierQuantityResponse {
string quantity_type = 1; // /quantity/date
BrainStatus status = 2; //Brain status response
}
```
## Predicate Schema APIs
- Predicates are relationships between a subject and an object entity type
- Each predicate has a unique name for a subject-object pair
- There are some standard predicates in all domains, e.g.
- type-of an entity (e.g. city) is a type of another entity (e.g. tier-1, tier-2)
- instance-of an entity (e.g. tier-1) has instances of another entity (e.g. city)
- contains an entity (e.g. city) contains another entity (e.g. ward, grid, JP)
- similar-to an entity (e.g. product) is similar to another entity (e.g. product) of same type
- There are non-standard domain centric predicates between specific subject-object pair
- e.g. river/flows-through/city
- There could be more than one predicates between the same subject-object (entity) pair
- e.g. store/inventory-count/product, store/price/product, store/sale-volume/product
- e.g. person/president-of/country, person/chief-justice-of/country, etc.
### Add a new Predicate between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate|
| -: | :- |
|**API Name**|**addPredicate**|
|**Description**|Add one or more predicates for a particular subject-object pair of entities|
|**Inputs**|domainName (string)subjectType (string)objectType (string)prediacteSet (set<PredicateName>)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|errorDoesNotExist({domain: domainName})errorDoesNotExist({domain: domainName, entity: subjectType})errorDoesNotExist({domain: domainName, entity: objectType})errorAlreadyExist({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)|
|**Examples**|**addPredicateToEntities**(common, person, country, ' '{president, prime\_minister, chief\_justice, home\_minister})|
---
```protobuf=
/
Predicates are relationships between a subject and an object entity type
Each predicate has a unique name for a subject-object pair
There are some standard predicates in all domains, e.g.
type-of -> An entity (e.g. city) is a type of another entity (e.g. tier-1, tier-2)
instance-of -> An entity (e.g. tier-1) has instances of another entity (e.g. city)
contains -> An entity (e.g. city) contains another entity (e.g. ward, grid, JP)
similar-to -> An entity (e.g. product) is similar to another entity (e.g. product) of same type
There are non-standard domain centric predicates between specific subject-object pair e.g. river/flows-through/city
There could be more than one predicates between the same subject-object (entity) pair
e.g. store/inventory-count/product, store/price/product, store/sale-volume/product
e.g. person/president-of/country, person/chief-justice-of/country, etc.
**/
//Add one or more predicates for a particular subject-object pair of entities
message AddPredicateRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //student
repeated string predicate = 4; //is_a
}
message AddPredicateResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get all Predicates between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate|
| -: | :- |
|**API Name**|**getPredicates**|
|**Description**|Get all predicates between a specific subject and object pair. One of them can be optional.|
|**Inputs**|domainName (string)subjectType (string) – if empty, return all predicates by objectTypeobjectType (string) – if empty, return all predicates by subjectType|
|**Output**|prediacteSet (set<PredicateName>)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})|
|**Examples**|**getPredicates**(common, person, country) – between person/ country**getPrediates**(common, person, <empty>) – where person is subject**getPredicates**(common, <empty>, country) – where country is object|
---
```protobuf=
//Get all predicates between a specific subject and object pair. One of them can be optional.
message GetPredicatesRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //Country
}
message GetPredicatesResponse {
repeated string predicate = 1; //citizen , president
BrainStatus status = 2; //Brain status response
}
```
### Check if a Predicate exists between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema|
| -: | :- |
|**API Name**|**hasPrediate**|
|**Description**|Checks whether a particular predicate already exists between a subject and object|
|**Inputs**|domainName (string)subjectType (string) objectType (string) predicateName (string)|
|**Output**|Boolean|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})|
|**Examples**|**hasPredicate**(common, person, country, president\_of)|
---
```protobuf=
//Checks whether a particular predicate already exists between a subject and object
message HasPredicateRequest {
string domain_name = 1; //common
string subject_type = 2; //person
string object_type = 3; //country
string predicate_name = 4; //president
}
message HasPredicateResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Rename a Predicate exists between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate|
| -: | :- |
|**API Name**|**renamePredicate**|
|**Description**|Change the name of a predicate from an old to a new name between a subject-object|
|**Inputs**|domainName (string)subjectType (string) objectType (string) oldPredicateName (string)newPredicateName (string)|
|**Output**|Status (ok or error code)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, entity: objectType, predicate: oldPredicateN})***errorAlreadyExist*s**({domain: domainName, entity: objectType, predicate: newPredicate})|
|**Examples**|**renamePredicate**(common, person, country, president\_of, is\_president\_of)|
---
```protobuf=
//Change the name of a predicate from an old to a new name between a subject-object
message RenamePredicateRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //country
string old_predicate_name = 4; //citizen
string new_predicate_name = 5; //nationality
}
message RenamePredicateResponse {
BrainStatus status = 1; //Brain status response
}
```
### Delete a Predicate exists between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate|
| -: | :- |
|**API Name**|**deletePredicate**|
|**Description**|Remove a predicate and all related elements from the knowledge graph|
|**Inputs**|domainName (string)subjectType (string) objectType (string) prediateName (string)|
|**Output**|Status (ok or error code)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, entity: objectType, predicate: predicateN})|
|**Examples**|**deletePredicate**(common, person, country, president\_of)|
---
```protobuf=
//Remove a predicate and all related elements from the knowledge graph
message DeletePredicateRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //student
string predicate_name = 4; //is_a
}
message DeletePredicateResponse {
BrainStatus status = 1; //Brain status response
}
```
## Predicate Qualifier Schema APIs
------------------------------------
- There are two types of predicates: absolute and qualified.
- an absolute predicate does not have any additional qualifiers (e.g. continent/contains/country)
- A qualified predicate may have one or more qualifiers
- e.g. predicate: person/president-of/country may have qualifiers such as:
- {start-date, end-date, order, length}
- Each predicate qualifier has a unique name (within the predicate)
- Each predicate qualifier is associated with a specific quantity
### Add a new Qualifier to a Predicate between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate/qualifier|
| -: | :- |
|**API Name**|**addQualifiersToPredicate**|
|**Description**|Add one or more qualifier to a predicate for a subject-object entity pair|
|**Inputs**|domainName (string)subjectType (string)objectType (string)prediateName (string)map<qualifierName, quantityType>|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|*errorDoesNotExist*({domain: domainName})*errorDoesNotExist*({domain: domainName, entity: subjectType})*errorDoesNotExist*({domain: domainName, entity: objectType})*errorDoesNotExist*({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)*errorAlreadyExist*({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName, qualifier: qualifierName)|
|**Example**|**addQualifierToPrediate**(common, person, country, president, ' '{start\_date: QuantityDate, end\_date: QuatityDate, order: QuantityOrder}|
---
```protobuf=
//Add one or more qualifier to a predicate for a subject-object entity pair
message AddQualifiersToPredicateRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //student
string predicate_name = 4; //is_a
map<string, string> qualifier_map = 5; // start_date:QuantityDate, end_date:QuantityDate
}
message AddQualifiersToPredicateResponse {
BrainStatus status = 1; //Brain status response
}
```
|**API Path**|/repository/knowledge/schema/predicate/qualifier|
| -: | :- |
|**API Name**|**addPredicateQualifier**|
|**Description**|Add one qualifier to a predicate|
|**Inputs**|domainName (string)subjectType (string)objectType (string)prediateName (string)qualifierName (string)quantityType (string)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)***errorAlreadyExist***({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName, qualifier: qualifierName)|
|**Example**|**addPredicateQualifier**(common, person, country, president, start\_date, QuantityDate)|
---
```protobuf=
//Add one qualifier to a predicate
message AddPredicateQualifierRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //student
string predicate_name = 4; //is_a
string qualifier_name = 5; //start_date
string qualifier_type = 6; //QuantityDate
}
message AddPredicateQualifierResponse {
BrainStatus status = 1; //Brain status response
}
```
### Get all Qualifiers of a Predicate between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate/qualifier|
| -: | :- |
|**API Name**|**getAllPredicateQualifiers**|
|**Description**|Returns all qualifiers associated with an predicate in a domain|
|**Inputs**|domainName (string)subjectType (string)objectType (string)prediateName (string)|
|**Output**|qualifierMap(map<qualifierName, quantityName>)|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})|
|**Example**|{/qualifier/start\_date /quantity/date} = **getAllPredicateQualifiers** (common, person, country, president)|
---
```protobuf=
//Returns all qualifiers associated with an predicate in a domain
message GetAllPredicateQualifiersRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //country
string predicate_name = 4; //president
}
message GetAllPredicateQualifiersResponse {
map<string, string> qualifier_map = 1; // {/qualifier/start_date, /quantity/date}
BrainStatus status = 2; //Brain status response
}
```
### Get the Quantity type of a Qualifier of a Predicate between a Subject-Object per Domain
|**API Path**|/repository/knowledge/schema/predicate/qualifier|
| -: | :- |
|**API Name**|**getPredicateQualifierQuantity**|
|**Description**|Return the quantity type of an predicate qualifier in the domain|
|**Inputs**|domainName (string)subjectType (string)objectType (string)prediateName (string)qualifierName (string)|
|**Output**|(quantityType (string), quantityUnit (string))|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)***errorDoesNotExist*** ({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName, qualifier: qualifierName)|
|**Example**|/quantity/date = **getPredicateQualifierQuantity** (common, person, country, president, start\_date)|
---
```protobuf=
//Return the quantity type of an predicate qualifier in the domain
message GetPredicateQualifierQuantityRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //country
string predicate_name = 4; //president
string qualifier_name = 5; //start_date
}
message GetPredicateQualifierQuantityResponse {
string qualifier_type = 1; // /quantity/date
BrainStatus status = 2; //Brain status response
}
```
### Check if a Qualifier exists for a Predicate between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/ predicate/qualifier|
| -: | :- |
|**API Name**|**hasPredicateQualifier**|
|**Description**|Returns true if qualifier is present in the predicate|
|**Inputs**|domainName (string)subjectType (string)objectType (string)<br>prediateName (string)qualifierName (string)|
|**Output**|Boolean |
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)***errorDoesNotExist*** ({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName, qualifier: qualifierName)|
|**Example**|Bool yes\_no = **hasPredicateQualifier** (common, person, country, president, start\_date)|
---
```protobuf=
//Returns true if qualifier is present in the predicate
message HasPredicateQualifierRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //country
string predicate_name = 4; //president
string qualifier_name = 5; //start_sate
}
message HasPredicateQualifierResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Rename a Qualifier of a Predicate exists between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/predicate/qualifier|
| -: | :- |
|**API Name**|**renameQualifierInPredicate**|
|**Description**|Renames a qualifier with a different name for an predicate in a domain|
|**Inputs**|domainName (string)subjectType (string)objectType (string)<br>prediateName (string)oldQualifierName (string)newQualifierName (string)|
|**Output**|Status (ok or error code) |
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)***errorDoesNotExist*** ({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName, qualifier: qualifierName)|
|**Example**|**renameQualifierInAttribute** (common, person, country, president, st, start\_date)|
---
```protobuf=
//Renames a qualifier with a different name for an predicate in a domain
message RenameQualifierInPredicateRequest {
string domain_name = 1; //Common
string subject_type = 2; //person
string object_type = 3; //country
string predicate_name = 4; //president
string old_qualifier_name = 5; //start_date
string new_qualifier_name = 6; //office_taken
}
message RenameQualifierInPredicateResponse {
BrainStatus status = 1; //Brain status response
}
```
### Delete a Qualifier of a Predicate exists between a Subject and Object pair in a Domain
|**API Path**|/repository/knowledge/schema/ predicate/qualifier|
| -: | :- |
|**API Name**|**deletePredicateQualifier**|
|**Description**|Deletes a qualifier from a predicate in a domain|
|**Inputs**|domainName (string)subjectType (string)objectType (string)<br>prediateName (string)qualifierName (string)|
|**Output**|Status (ok or error code) |
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: subjectType})***errorDoesNotExist***({domain: domainName, entity: objectType})***errorDoesNotExist***({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName)***errorDoesNotExist*** ({domain: domainName, subject: subjectType, ' 'object: objectType, predicate: predicateName, qualifier: qualifierName)|
|**Example**|**deletePredicateQualifier**(common, person, country, president, start\_date)|
---
```protobuf=
//Add an attribute-group to an entity in a domain
//Attribute group are attribute which are grouped together as they corelate with one another
message AddAttributeGroupRequest {
string domain_name = 1; //Common
string entity_type = 2; // person
string attribute_group_name = 3; //monatery
repeated string attribute_name = 4; // salary, bills
}
message AddAttributeGroupResponse {
BrainStatus status = 1; //Brain status response
}
```
## Attribute Group APIs
### Add new Attribute Group to an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute-group|
| :- | :- |
|**API Name**|**addAttributeGroup**|
|**Description**|Add an attribute-group to an entity in a domain|
|**Inputs**|domainName (string)<br>entityType (string)attributeGroupName (string) AttributeSet (set<attributeName>)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})<br>***errorDoesNotExist***({domain: domainName, entity: entityType})<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: [attributeNames] })<br>**errorAlreadyExist**({domain: domainName, entity: entityType, ' 'attributeGroup: attributeGroupName)|
|**Example**|**addAttributeGroup** (common, country, wealth, [gdp])|
---
```protobuf=
```
### Add new Attribute into an Attribute Group to an Entity in a Domain
|**API Path**|/repository/knowledge/schema/attribute-group|
| :- | :- |
|**API Name**|**addAttributeToAttributeGroup**|
|**Description**|Add an attribute to attribute-group to an entity in a domain|
|**Inputs**|domainName (string)<br>entityType (string)attributeGroupName (string) AttributeSet (set<attributeName>)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({domain: domainName})<br>***errorDoesNotExist***({domain: domainName, entity: entityType})<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attribute: [attributeNames] })<br>***errorDoesNotExist*** ({domain: domainName, entity: entityType, ' 'attributeGroup: attributeGroupName)|
|**Example**|**addAttributeGroup** (common, country, wealth, [gdp, revenue])|
---
```protobuf=
//Add an attribute to attribute-group to an entity in a domain
message AddAttributeToAttributeGroupRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
string attribute_group_name = 3; //monatery - contains salary and bills
repeated string attribute_name = 4; //worth
}
message AddAttributeToAttributeGroupResponse {
BrainStatus status = 1; //Brain status response
}
```
### Check Attribute Group exists
|**API Path**|/repository/knowledge/schema/attribute-group|
| :- | :- |
|**API Name**|**hasAttributeGroup**|
|**Description**|Returns true if attribute-group is present in the entity in a domain|
|**Inputs**|domainName (string)<br>entityType (string)attributeGroupName (string) |
|**Output**|Boolean|
|**Errors**|***errorDoesNotExist***({domain: domainName})<br>***errorDoesNotExist***({domain: domainName, entity: entityType})<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attributeGroup: attributeGroupName})|
|**Example**|Bool yes\_no = **hasAttributeGroup** (common, country, wealth)|
---
```protobuf=
//Returns true if attribute-group is present in the entity in a domain
message HasAttributeGroupRequest {
string domain_name = 1; //Common
string entity_type = 2; // person
string attribute_group_name = 3; //monatery
}
message HasAttributeGroupResponse {
bool result = 1; // true/false
BrainStatus status = 2; //Brain status response
}
```
### Rename Attribute Group to an Entity in a Domain
---------------------------------------------------
|**API Path**|/repository/knowledge/schema/attribute-group|
| :- | :- |
|**API Name**|**renameAttributeGroup**|
|**Description**|Renames a attribute-group with a different name of an entity in a domain|
|**Inputs**|domainName (string)<br>entityType (string)oldAttributeGroupName (string)newAttributeGroupName (string)|
|**Output**|Boolean|
|**Errors**|***errorDoesNotExist***({domain: domainName})<br>***errorDoesNotExist***({domain: domainName, entity: entityType})<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attributeGroup: oldAttributeGroupName })<br>***errorAlreadyExists*** ({domain: domainName, entity: entityType, attributeGroup: newAttributeGroupName })|
|**Example**|Bool yes\_no = **hasAttributeGroup** (common, country, wealth)|
---
```protobuf=
//Renames a attribute-group with a different name of an entity in a domain
message RenameAttributeGroupRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
string old_attribute_group_name = 3; //monatery
string new_attribute_group_name = 4; //wealth
}
message RenameAttributeGroupResponse {
BrainStatus status = 1; //Brain status response
}
```
### Delete Attribute from an Attribute Group to an Entity in a Domain
---------------------------------------------------------------------
|**API Path**|/repository/knowledge/schema/attribute-group|
| :- | :- |
|**API Name**|**deleteAttributeFromAttributeGroup**|
|**Description**|Renames a attribute-group with a different name of an entity in a domain|
|**Inputs**|domainName (string)<br>entityType (string)attributeGroupName (string)attributeName (string)|
|**Output**|Status (ok or error code) |
|**Errors**|***errorDoesNotExist***({domain: domainName})<br>***errorDoesNotExist***({domain: domainName, entity: entityType})<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attributeGroup: attributeGroupName })<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attributeGroup: attributeGroupName, attribute: attributeName })|
|**Example**|**deleteAttributeFromAttributeGroup** (common, country, wealth, gdp)|
---
```protobuf=
//Delete a attribute from attribute-group
message DeleteAttributeFromAttributeGroupRequest {
string domain_name = 1; //Common
string entity_type = 2; // person
string attribute_name = 3; // worth
string attribute_group_name = 4; // monatery - contains salary, worth, bills
}
message DeleteAttributeFromAttributeGroupResponse {
BrainStatus status = 1; //Brain status response
```
### Delete Attribute Group
|**API Path**|/repository/knowledge/schema/attribute-group|
| :- | :- |
|**API Name**|**deleteAttributeGroup**|
|**Description**|Delete an attribute-group to an entity in a domain|
|**Inputs**|domainName (string)<br>entityType (string)attributeGroupName (string)|
|**Output**|Status (ok or error code) |
|**Errors**|***errorDoesNotExist***({domain: domainName})<br>***errorDoesNotExist***({domain: domainName, entity: entityType})<br>***errorDoesNotExist***({domain: domainName, entity: entityType, attributeGroup: attributeGroupName })|
|**Example**|**deleteAttributeGroup** (common, country, wealth)|
---
```protobuf=
//Delete an attribute-group to an entity in a domain
message DeleteAttributeGroupRequest {
string domain_name = 1; //Common
string entity_type = 2; //person
string attribute_group_name = 3; //monatery
message DeleteAttributeGroupResponse {
BrainStatus status = 1; //Brain status response
}
```
# Knowledge Nugget APIs
Nugget APIs are meant to manage the data within the knowledge repository. Data here means the actual instance data of entities and predicates (basically nodes and edge to the graph).
Things in Knowledge store will be represented via its ID annotation. (Unit32)
---
```protobuf=
service KnowledgeNuggetService {
/* Method to serve the Nugget Service APIs */
rpc serve(KnowledgeNuggetServiceRequest) returns (KnowledgeNuggetServiceResponse) {}
}
message KnowledgeNuggetServiceRequest{
oneof request{
AddEntityInstanceRequest add_entity_instance_request = 1;
DeleteEntityInstanceRequest delete_entity_instance_request = 2;
AddBizIDsToEntityInstanceRequest add_biz_ids_to_entity_instance_request = 3;
SetAttributeOfEntityRequest set_attribute_of_entity_request = 4;
GetAttributeOfEntityRequest get_attribute_of_entity_request = 5;
GetEntitiesByAttributeRequest get_entities_by_attribute_request = 6;
GetAttributeValuesByEntityQualifierFilterRequest get_attribute_values_by_entity_qualifier_filter_request = 7;
GetQualifierValuesByEntityAttributeFilterRequest get_qualifier_values_by_entity_attribute_filter_request = 8;
GetAbsoluteAttributesOfEntityInstanceRequest get_absolute_attributes_of_entity_instance_request = 9;
AddPredicateInstanceRequest add_predicate_instance_request = 10;
GetPredicateInstancesRequest get_predicate_instances_request = 11;
DeletePredicateInstanceByIdRequest delete_predicate_instance_by_id_request = 12;
DeletePredicateInstancesRequest delete_predicate_instances_request = 13;
GetObjectIdsForSubjectAndPredicateRequest get_object_ids_for_subject_and_predicate_request = 14;
}
}
message KnowledgeNuggetServiceResponse{
oneof response{
AddEntityInstanceResponse add_entity_instance_response = 1;
DeleteEntityInstanceResponse delete_entity_instance_response = 2;
AddBizIDsToEntityInstanceResponse add_biz_ids_to_entity_instance_response = 3;
SetAttributeOfEntityResponse set_attribute_of_entity_response = 4;
GetAttributeOfEntityResponse get_attribute_of_entity_response = 5;
GetEntitiesByAttributeResponse get_entities_by_attribute_response = 6;
GetAttributeValuesByEntityQualifierFilterResponse get_attribute_values_by_entity_qualifier_filter_response = 7;
GetQualifierValuesByEntityAttributeFilterResponse get_qualifier_values_by_entity_attribute_filter_response = 8;
GetAbsoluteAttributesOfEntityInstanceResponse get_absolute_attributes_of_entity_instance_response = 9;
AddPredicateInstanceResponse add_predicate_instance_response = 10;
GetPredicateInstancesResponse get_predicate_instances_response = 11;
DeletePredicateInstanceByIdResponse delete_predicate_instance_by_id_response = 12;
DeletePredicateInstancesResponse delete_predicate_instances_response = 13;
GetObjectIdsForSubjectAndPredicateRequest get_object_ids_for_subject_and_predicate_request = 14;
}
}
```
## Entity Instance APIs
### Add an entity instance for an entity type in a domain
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**addEntityInstance**|
|**Description**|Adding an entity instance of an entity type|
|**Input**|domainName(String)<br>entityType(String)<br>{ primaryBizID(String), primaryBizIDValue(String)} <br>alternativeBizIDs(<BizID, BizIDValue>)<br>names(<language, BrainEntityName>)<br>attributes(<attributeName, BrainAttribute>)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***() – domain, entity type, primary bizID type, language, attribute**errorAlreadyExist() –** primary biz ID value** **errorSchemaMissmatch()** –attribute quantity schema miss match, value range miss match|
|**Examples**|**addEntityInstance** (common, person,{ pancard : 1234 }, {adharcard : 56}, {‘en’ : {‘krishna’, <kk, kkt, krish>},{age :18, gender: Male} )|
---
```protobuf=
/* Adding an entity instance of an entity type */
message AddEntityInstanceRequest {
string domain_name = 1;
string entity_type = 2;
jio.brain.proto.knowledge.base.BizId primary_biz_id = 3;
repeated jio.brain.proto.knowledge.base.BizId alternative_biz_ids = 4;
map<string, jio.brain.proto.entity.BrainEntityName> names = 5;
map<string, jio.brain.proto.quantity.BrainQuantity> attributes = 6;
}
message AddEntityInstanceResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
### Delete an Entity Instance
*only allowing to delete the entity by BrainID so that any ambiguity should not lead to wrong delete operation*
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**deleteEntityInstance**|
|**Description**|Deleting an entity instance of an entity type|
|**Input**|brainID(BrainID)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***({BrainID: brainID })|
|**Examples**|**deleteEntityInstance1234)**|
---
```protobuf=
/* Deleting an entity instance of an entity type */
message DeleteEntityInstanceRequest {
uint64 brain_id = 1;
}
message DeleteEntityInstanceResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
### Add additional business IDs to entity instance
*primary bizID cannot be added like this*
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**addBizIDsToEntityInstance**|
|**Description**|Adding additional alternative business ID to an entity instance|
|**Input**|entityID (BrainID)<br>alternativeBizIDs(<BizID, BizIDValue>)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|***errorDoesNotExist***() – entityID, business ID type **errorAlreadyExist() –** business ID, business ID Value**errorFormatMissmatch()** – business ID Value format miss match|
|**Examples**|**addBizIDsToEntityInstance** (20001,{ pancard : 1234, adharcard : 56})|
---
```protobuf=
/* Adding additional alternative business ID to an entity instance */
message AddBizIDsToEntityInstanceRequest {
uint64 entity_id = 1;
repeated jio.brain.proto.knowledge.base.BizId alternative_biz_ids = 2;
}
message AddBizIDsToEntityInstanceResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
## Entity Enumeration APIs
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**getEntityInstancesOfType**|
|**Description**|Listing all the entity instance of a given entity type|
|**Input**|domain, entity type & limit |
|**Output**|List<BrainEntityInstances>|
|**Errors**|***errorDoesNotExist***() – entityID, business ID type **errorAlreadyExist() –** business ID, business ID Value**errorFormatMissmatch()** – business ID Value format miss match|
|**Examples**|**getEntityInstancesOfType** (domain = "common", entity_type = "country", limit =4)|
## Attribute & Qualifier APIs
### Set Attribute of an entity (with all qualifiers)
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**setAttributeOfEntity**|
|**Description**|Set value of an attribute for a certain qualifier value combinations for an entity|
|**Input**|domainName (string)entityType (string)entityID (BrainID)<br>attributeName (string)attributeQuantity (Quantity)[map<qualifierName, qualifierQuantity>] – could be empty|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|*errorDoesNotExist*({domain: domainName})*errorDoesNotExist*({domain: domainName, entity: entityType})*errorDoesNotExist*({domain: domainName, entity: entityType, attribute: attributeName})*errorDoesNotExist*({domain: domainName, entity: entityType, ' 'entity: attributeName, qualifier: qualifierName})<br>errorSchemaMissmatch()|
|**Examples**|**setAttributeOfEntity**(common, country, ID(India), GDP, 8 GDP Quantity , {year: 1995})|
---
```protobuf=
/* Set value of an attribute for a certain qualifier value combinations for an entity */
message SetAttributeOfEntityRequest {
string domain_name = 1;
string entity_type = 2;
uint64 entity_id = 3;
string attribute_name = 4;
jio.brain.proto.quantity.BrainQuantity attribute_quantity = 5;
map<string, jio.brain.proto.quantity.BrainQuantity> qualifiers = 6;
}
message SetAttributeOfEntityResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
### Get Attribute Values of an entity instance of an entity type for a qualifier condition
E.g. What are the GDP values of India from year 2000 onwards?
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**getAttributeOfEntity**|
|**Description**|Get the value of an attribute for a certain qualifier value combinations for an entity instance|
|**Input**|domainName (string)entityType (string)attributeName (string)entityInstance (EntityInstance) || entityID : BrainIDqualifierCondition|
|**Output**|AttributeValue table – one for each qualifier combinationPairs of: {(qualifierCombination, attributeValue)}|
|**Errors**|*errorDoesNotExist*({domain: domainName})*errorDoesNotExist*({domain: domainName, entity: entityType})*errorDoesNotExist*({domain: domainName, entity: entityType, attribute: attributeName})*errorDoesNotExist*({domain: domainName, entity: entityType, ' 'entity: attributeName, qualifier: qualifierName}) – in the qualifierCondition|
|**Examples**|**getAttributeOfEntity**(common, country, EntityInstance(India), gdp, {year >= 2000})|
---
```protobuf=
/* Get the value of an attribute for a certain qualifier value combinations for an entity instance */
message GetAttributeOfEntityRequest {
string domain_name = 1;
string entity_type = 2;
string attribute_name = 3;
uint64 entity_id = 4;
string qualifier_condition = 5;
}
message GetAttributeOfEntityResponse {
jio.brain.proto.base.BrainStatus status = 1;
map<string, jio.brain.proto.quantity.BrainQuantity> attribute_value_table = 2;
}
```
### Get all entities that satisfy a particular AttributeCondition and QualifierConditions
E.g. Which countries had a GDP more than USD 100B in year 2021?
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**getEntitiesByAttribute**|
|**Description**|Get the list of all entities that satisfy certain attribute-qualifier condition|
|**Input**|domainName (string)entityType (string)attributeConditionqualifierCondition|
|**Output**|EntitySet|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName}) – for each attribute in attributeCondition***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName, qualifier: qualifierName}) – per qualifier in qualifierCondition|
|**Examples**|{EntityInstance(India), EntityInstance(US)}=**getEntitiesByAttribute**(common, country, “GDP > USD100”, {year =2021}})|
---
```protobuf=
/* Get the list of all entities that satisfy certain attribute-qualifier condition */
message GetEntitiesByAttributeRequest {
string domain_name = 1;
string entity_type = 2;
string attribute_condition = 3;
string qualifier_condition = 4;
}
message GetEntitiesByAttributeResponse {
jio.brain.proto.base.BrainStatus status = 1;
repeated jio.brain.proto.knowledge.base.Entity entity_set = 2;
}
```
### Get Qualified Attribute Values of entity instances for a given qualifier
E.g. What is the GDP India in 1998?
What is the GDP & Population of India in 1998?
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**getAttributeValuesByEntityQualifierFilter**|
|**Description**|Get the attribute name an value map for a given entity instance following a qualifier condition |
|**Input**|domainName (string)entityType (string)<br>entityID (BrainID) || entityInstance (EntityInstance)qualifierConditionattributeNameSet<AttributeName>|
|**Output**|AttributeValueSet|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName}) – for each attribute in attributeCondition***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName, qualifier: qualifierName}) – per qualifier in qualifierCondition|
|**Examples**|{‘GDP’: 8, ‘POPULATION’ : 1.2B}=**getAttributeValuesByEntityQualifierFilter** (common, country,ID(India), {year =1998}}, <“GDP”, “POPULATION”>)|
*not adding multiple entity instance as start/discovery node as it time complexity will increase*
```
{IN :{‘GDP’: 8, ‘POPULATION’ : 1.2B}, US: {‘GDP’: 10, ‘POPULATION’ : 1.5B}, }=**getAttributeValuesByEntityQualifierFilter** (common, country,<ID(India), ID(US)> , {year =1998}}, <“GDP”, “POPULATION”>)
```
---
```protobuf=
/* Get the attribute name an value map for a given entity instance following a qualifier condition */
message GetAttributeValuesByEntityQualifierFilterRequest {
string domain_name = 1;
string entity_type = 2;
uint64 entity_id = 3;
string qualifier_condition = 4;
repeated string attribute_name_set = 5;
}
message GetAttributeValuesByEntityQualifierFilterResponse {
jio.brain.proto.base.BrainStatus status = 1;
map<string, jio.brain.proto.quantity.BrainQuantity> attribute_value_set = 2;
}
```
### Get Qualifiers of a given Attribute Condition for an entity Instance
E.g. When was the GDP of India above <value>?
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**getQualifierValuesByEntityAttributeFilter**|
|**Description**|Get the qualifier name an value map for a given entity instance following a attribute condition |
|**Input**|domainName (string)entityType (string)<br>entityID (BrainID) || entityInstance (EntityInstance)attributeConditionqualifierNameSet<QualifierName>|
|**Output**|QualifierValueSet|
|**Errors**|***errorDoesNotExist***({domain: domainName})***errorDoesNotExist***({domain: domainName, entity: entityType})***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName}) – for each attribute in attributeCondition***errorDoesNotExist***({domain: domainName, entity: entityType, ' 'attribute: attributeName, qualifier: qualifierName}) – per qualifier in qualifierCondition|
|**Examples**|{year =1998} = **getQualifierValuesByEntityAttributeFilter** (common, country,ID(India) , {“GDP > USD100”})|
---
```protobuf=
/* Get the qualifier name an value map for a given entity instance following a attribute condition */
message GetQualifierValuesByEntityAttributeFilterRequest {
string domain_name = 1;
string entity_type = 2;
uint64 entity_id = 3;
string attribute_condition = 4;
repeated string qualifier_name_set = 5;
}
message GetQualifierValuesByEntityAttributeFilterResponse {
jio.brain.proto.base.BrainStatus status = 1;
map<string, jio.brain.proto.quantity.BrainQuantity> qualifier_value_set = 2;
}
```
### Get one or more absolute Attributes of an entity instance
|**API Path**|/repository/knowledge/nugget|
| -: | :- |
|**API Name**|**getAbsoluteAttributesOfEntityInstance**|
|**Description**|Get the attribute name and value for set for request absolute attributes of a given entity instance|
|**Input**|domainName (string)entityType (string)<br>entityInstance (EntityInstance) || entityID : BrainIDattributeNameSet<String>|
|**Output**|AttributeValue tablePairs of: {(attributeName, attributeValue)}|
|**Errors**|*errorDoesNotExist() – Domain, Entity Type, BrainID, AttributeName*<br>errorSchemaMissmatch() – attribute is not an absolute attribute|
|**Examples**|**getAbsoluteAttributesOfEntityInstance** (common, country, ID(India), <founding\_date, area>)|
---
```protobuf=
/* Get the attribute name and value for set for request absolute attributes of a given entity instance */
message GetAbsoluteAttributesOfEntityInstanceRequest {
string domain_name = 1;
string entity_type = 2;
uint64 entity_id = 3;
repeated string attribute_name_set = 4;
}
message GetAbsoluteAttributesOfEntityInstanceResponse {
jio.brain.proto.base.BrainStatus status = 1;
map<string, jio.brain.proto.quantity.BrainQuantity> attribute_value_table = 2;
}
```
## Predicate APIs
### Add a predicate instance between two entity instances
Predicate instance can connect entity from different domains
Eg. Connecting two person via friendship predicate
|**API Path**|/repository/knowledge/nugget/predicate|
| -: | :- |
|**API Name**|**AddPredicateInstance**|
|**Description**|Add a predicate instance between two entity instances |
|**Input**|Domain(String)predicateName(String)subjectID (BrainID)<br>objectID(BrainID) <br>map<qualifierName, qualifierValue> (qualifierValue is a Quantity )|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|*errorDoesNotExist() – Domain,* subjectID*,* objectID*, BrainID,* qualifierName*<br>errorSchemaMissmatch() – qualifierValue|
|**Examples**|**AddPredicateInstance** (‘telecom’, ‘connected’, cell-1, device-1, <start\_time : 21-02-2022>)|
---
```protobuf=
/* Add a predicate instance between two entity instances */
message AddPredicateInstanceRequest {
string domain_name = 1;
string entity_type = 2;
uint64 subject_id = 3;
uint64 object_id = 4;
map<string, jio.brain.proto.quantity.BrainQuantity> qualifiers = 5;
}
message AddPredicateInstanceResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
### Get a predicate between given subject and object instance
-------------------------------------------------------------
|**API Path**|/repository/knowledge/nugget/predicate|
| -: | :- |
|**API Name**|**getPredicateInstances**|
|**Description**|Get a predicate instance between two entity instances |
|**Input**|Domain(String)<br>predicateName(String)subjectID (BrainID)<br>objectID(BrainID) |
|**Output**|<predicateID, <map<qualifierName, qualifierValue>>>|
|**Errors**|*errorDoesNotExist() – Domain,* subjectID*,* objectID*, BrainID,* qualifierName*<br>errorSchemaMissmatch() – qualifierValue|
|**Examples**|**AddPredicateInstance** (‘telecom’, ‘connected’, cell-1, device-1, <start\_time : 21-02-2022>)|
---
```protobuf=
/* Get a predicate between given subject and object instance */
message GetPredicateInstancesRequest {
string domain_name = 1;
string predicate_name = 2;
uint64 subject_id = 3;
uint64 object_id = 4;
}
message GetPredicateInstancesResponse {
jio.brain.proto.base.BrainStatus status = 1;
uint64 predicate_id = 2;
map<string, jio.brain.proto.quantity.BrainQuantity> qualifier_value_set = 3;
}
```
### Delete predicate given and predicate instance ID
We are taking the predicate instance ID to remove any ambiguity
|**API Path**|/repository/knowledge/nugget/predicate|
| -: | :- |
|**API Name**|**deletePredicateInstanceByID**|
|**Description**|delete a predicate instance given the ID|
|**Input**|Domain(String)<br>predicateName(String)predicateID|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|*errorDoesNotExist() – Domain,* predicateName, predicateID|
|**Examples**|**deletePredicateInstance** (‘telecom’, ‘connected’, 40001)|
---
```protobuf=
/* Delete predicate given and predicate instance ID */
message DeletePredicateInstanceByIdRequest {
string domain_name = 1;
string predicate_name = 2;
uint64 predicate_id = 3;
}
message DeletePredicateInstanceByIdResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
### Delete Predicate Instances given subject ID, Object ID & Predicate Name
---------------------------------------------------------------------------
|**API Path**|/repository/knowledge/nugget/predicate|
| -: | :- |
|**API Name**|**deletePredicateInstances**|
|**Description**|delete a predicate instance given subject and object node and relationship type|
|**Input**|Domain(String)<br>predicateName(String)subjectID(String)<br>objectID(String)|
|**Output**|Status (all ok or one of the error codes with parameters)|
|**Errors**|*errorDoesNotExist() – Domain,* predicateName, subjectID, objectID|
|**Examples**|**deletePredicateInstance** (‘telecom’, ‘connected’, 2001, 2002)|
---
```protobuf=
/* Delete Predicate Instances given subject ID, Object ID & Predicate Name */
message DeletePredicateInstancesRequest {
string domain_name = 1;
string predicate_name = 2;
uint64 subject_id = 3;
uint64 object_id = 4;
}
message DeletePredicateInstancesResponse {
jio.brain.proto.base.BrainStatus status = 1;
}
```
### Get Object IDs for a given Subject, Predicate & Qualifier Condition
------------------------------------------------------------------------
List of all colleagues of a Krishna
List of all colleagues of a Krishna working together from last 6 months
|**API Path**|/repository/knowledge/nugget/predicate|
| -: | :- |
|**API Name**|**getObjectIdsForSubjectandPredicate**|
|**Description**|List all the objects of given subject ID and predicate name |
|**Input**|Domain(String)<br>predicateName(String)subjectID(String)<br>qualifierCondition|
|**Output**|ObjectIdSet<BrainID>|
|**Errors**|*errorDoesNotExist() – Domain,* predicateName, subjectID, qualifierName in the condition|
|**Examples**|{20021, 200202, 2002211}= **getObjectIdsForSubjectandPredicate** (‘hrplatform, ‘**colleagues’**, ID(Krishna))<br>{20021}= **getObjectIdsForSubjectandPredicate** (‘hrplatform, ‘**colleagues’**, ID(Krishna), {start\_link> 2020})|
---
```protobuf=
/* Get Object IDs for a given Subject, Predicate & Qualifier Condition */
message GetObjectIdsForSubjectAndPredicateRequest {
string domain_name = 1;
string predicate_name = 2;
uint64 subject_id = 3;
string qualifier_condition = 4;
}
message GetObjectIdsForSubjectAndPredicateResponse {
jio.brain.proto.base.BrainStatus status = 1;
map<string, uint64> object_id_set = 3;
}
```
### Get Predicate/Relations between two Entity instances
|**API Path**|/repository/knowledge/nugget/predicate|
| -: | :- |
|**API Name**|**getPredicatesbetweentwoEntityInstances**|
|**Description**|List all the relations between two entity instances|
|**Input**|domainName (string)entityType (string)entityID (BrainID)|
|**Output**|PredicateNameSet<PredicateName>|
|**Errors**|*errorDoesNotExist() – Domain,* entityType, entityID,|
|**Examples**|{‘friends’, ‘batchmates’}= **getPredicatesbetweentwoEntityInstances**((‘common’, ‘person**’**, ID(Navdeep)) , (‘common’, ‘person**’**, ID(Prashant)) )|
**Note: proto not written
### Get Attributes of Objects for a given Subject, Predicate & Qualifier Condition
Better call getObjectIdsForSubjectandPredicate and then for required call getAttributeForEntityInstance