List user properties from Microsoft Graph API - azure-active-directory

We are making integrations to Azure AD for various companies. As a part of this work we have to ask which fields in their systems needs to be mapped over to our system.
Because people don't actually use the system names day to day, most people we encounter have no clue of this.
Given correct credentials, is it possible to either fetch all properties that a User object can return or is there a predefined list already?
The closest I could find have been this one, but the url says "previous version", so I'm not sure if it's been changed or not.
I tried finding it via the API using $select=*, but as you may know that will just give the default list of properties.

The available properties are documented in the user resource section of the Graph documentation. The JSON prototype for the user looks like this:
{
"aboutMe": "string",
"accountEnabled": true,
"ageGroup": "string",
"assignedLicenses": [{"#odata.type": "microsoft.graph.assignedLicense"}],
"assignedPlans": [{"#odata.type": "microsoft.graph.assignedPlan"}],
"birthday": "String (timestamp)",
"businessPhones": ["string"],
"city": "string",
"companyName": "string",
"consentProvidedForMinor": "string",
"country": "string",
"department": "string",
"displayName": "string",
"employeeId": "string",
"faxNumber" : "string",
"givenName": "string",
"hireDate": "String (timestamp)",
"id": "string (identifier)",
"imAddresses": ["string"],
"interests": ["string"],
"jobTitle": "string",
"legalAgeGroupClassification": "string",
"licenseAssignmentStates": [{"#odata.type": "microsoft.graph.licenseAssignmentState"}],
"mail": "string",
"mailboxSettings": {"#odata.type": "microsoft.graph.mailboxSettings"},
"mailNickname": "string",
"mobilePhone": "string",
"mySite": "string",
"officeLocation": "string",
"onPremisesDistinguishedName": "string",
"onPremisesDomainName": "string",
"onPremisesExtensionAttributes": {"#odata.type": "microsoft.graph.onPremisesExtensionAttributes"},
"onPremisesImmutableId": "string",
"onPremisesLastSyncDateTime": "String (timestamp)",
"onPremisesProvisioningErrors": [{"#odata.type": "microsoft.graph.onPremisesProvisioningError"}],
"onPremisesSamAccountName": "string",
"onPremisesSecurityIdentifier": "string",
"onPremisesSyncEnabled": true,
"onPremisesUserPrincipalName": "string",
"otherMails": "string",
"passwordPolicies": "string",
"passwordProfile": {"#odata.type": "microsoft.graph.passwordProfile"},
"pastProjects": ["string"],
"postalCode": "string",
"preferredDataLocation": "string",
"preferredLanguage": "string",
"preferredName": "string",
"provisionedPlans": [{"#odata.type": "microsoft.graph.provisionedPlan"}],
"proxyAddresses": ["string"],
"responsibilities": ["string"],
"schools": ["string"],
"showInAddressList": true,
"skills": ["string"],
"state": "string",
"streetAddress": "string",
"surname": "string",
"usageLocation": "string",
"userPrincipalName": "string",
"userType": "string",
"calendar": { "#odata.type": "microsoft.graph.calendar" },
"calendarGroups": [{ "#odata.type": "microsoft.graph.calendarGroup" }],
"calendarView": [{ "#odata.type": "microsoft.graph.event" }],
"calendars": [ {"#odata.type": "microsoft.graph.calendar"} ],
"contacts": [ { "#odata.type": "microsoft.graph.contact" } ],
"contactFolders": [ { "#odata.type": "microsoft.graph.contactFolder" } ],
"createdObjects": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"directReports": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"drive": { "#odata.type": "microsoft.graph.drive" },
"drives": [ { "#odata.type": "microsoft.graph.drive" } ],
"events": [ { "#odata.type": "microsoft.graph.event" } ],
"inferenceClassification": { "#odata.type": "microsoft.graph.inferenceClassification" },
"mailFolders": [ { "#odata.type": "microsoft.graph.mailFolder" } ],
"manager": { "#odata.type": "microsoft.graph.directoryObject" },
"memberOf": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"messages": [ { "#odata.type": "microsoft.graph.message" } ],
"outlook": { "#odata.type": "microsoft.graph.outlookUser" },
"ownedDevices": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"ownedObjects": [ { "#odata.type": "microsoft.graph.directoryObject" } ],
"photo": { "#odata.type": "microsoft.graph.profilePhoto" },
"registeredDevices": [ { "#odata.type": "microsoft.graph.directoryObject" } ]
}
In order to return a specific set of properties, you need to list each of them in your $select statement. You cannot use a wildcard (*) to retrieve the entire set. The simpliest method is to start with the default $select and add the aditional properties you're looking for:
$select=businessPhones,displayName,givenName,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName,id

Related

JSON Schema: Check the array to validate if a certain block of JSON objects is contained in it

I have a JSON array of arbitrary length. Each item in the array is a nested block of JSON objects, they all have same properties but different values.
I need a JSON schema to check the array if the last block in the array has the values defined in the schema.
How should the scheme be defined so that it only considers the last block in the array and ignores all the blocks before in the array?
My current solution successfully validates the JSON objects if there is only one block in the array. As soon as I have more blocks, it fails because all the others are not valid against my schema - for sure, this corresponds to the expected behaviour.
In my example, the JSON array contains two nested blocks of JSON objects. These differ for the following items:
event.action = "[load|button]"
event.label = "[journey:device-only|submit,journey:device-only]"
type = "[page|track]"
An example for my data are:
[
{
"page": {
"path": "order/checkout/summary",
"language": "en"
},
"cart": {
"ordercase": "neworder",
"product_list": [
{
"name": "Apple iPhone 14 Plus",
"quantity": 1,
"price": 1000
}
]
},
"event": {
"action": "load",
"label": "journey:device-only"
},
"type": "page"
},
{
"page": {
"path": "order/checkout/summary",
"language": "en"
},
"cart": {
"ordercase": "neworder",
"product_list": [
{
"name": "Apple iPhone 14 Plus",
"quantity": 1,
"price": 1000
}
]
},
"event": {
"action": "button",
"label": "submit,journey:device-only",
},
"type": "track"
}
]
And the schema I use which works fine for the second block if the block would be the only one in the array:
{
"type": "array",
"$schema": "http://json-schema.org/draft-07/schema#",
"items": {
"type": "object",
"required": ["event", "page", "type"],
"properties": {
"page": {
"type": "object",
"properties": {
"path": {
"const": "order/checkout/summary"
},
"language": {
"enum": ["de", "fr", "it", "en"]
}
},
"required": ["path", "language"]
},
"event": {
"type": "object",
"additionalProperties": false,
"properties": {
"action": {
"const": "button"
},
"label": {
"type": "string",
"pattern": "^[-_:, a-z0-9]*$",
"allOf": [
{
"type": "string",
"pattern": "^\\S*(?:(submit,|,submit))\\S*$"
},
{
"type": "string",
"pattern": "^\\S*(journey:(?:(device-only|device-plus)))\\S*$"
}
]
}
},
"required": ["action", "label"]
},
"type": {
"enum": ["track", "string"]
}
}
}
}

How to create array json schema for an array string which contains some fixed values and may have other additonal values

So I have this json schema:-
{
"type": "object",
"properties": {
"campaignType": {
"type": "string",
"enum": [
"export"
]
},
"clientid": {
"type": "integer",
"minimum": 1
},
"select": {
"type": "object",
"minProperties": 1,
"anyOf": [
{
"required": [
"list"
]
},
{
"required": [
"segment"
]
}
],
"properties": {
"list": {
"type": "array",
"items": {
"type": "integer"
}
},
"segment": {
"type": "array",
"items": {
"type": "integer"
}
}
}
},
"attributes": {
"type": "array",
"minItems": 2,
"items": {
"type": "string",
"contains": ["fk", "uid"]
}
}
},
"required": [
"campaignType",
"clientid",
"select",
"attributes"
]
}
Here I want to have attributes field to have value "fk", "uid" fixed and must allow other field values with "fk" and "uid".
with this following code I am getting error while passing additonal values:-
{
"campaignType":"export",
"clientid":107311,
"select":{
"segment":[30]
},
"attributes":["uid","fk", "att1"]
}
error unmarshaling properties from json: error unmarshaling items from json: json: cannot unmarshal object into Go value of type []*jsonschema.Schema
how do I fix it?
The value of contains in your schema must be a schema:
According to your question, maybe change the "attributes" schema to:
"attributes": {
"type": "array",
"minItems": 2,
"items": [ { "const": "fk" }, { "const": "uid" } ],
"additionalItems": {
"type": "string"
}
}

In Avro schema, how to wrap the array to an object and put it as a union instead of putting just array as union

I have the following data and I want to wrap the OPTIONAL array as an object and then put in as a union but since I am new to this, I am not sure how to do this.
This is how I have done so far so could someone help me correct the below structure in the expected output. Note that this dataRefs is an optional field and this entire structure may or may not be present.
{
"name": "dataRefs",
"default": null,
"type": ["null",
{
"type": "array",
"items": {
"name": "dataRef",
"type": "record",
"fields": [
{
"name": "dataId",
"type": "string",
"avro.java.string": "String"
},
{
"name": "email",
"type": ["null" ,"string"],
"avro.java.string": "String"
},
{
"name": "phone",
"type": ["null" ,"string"],
"avro.java.string": "String"
},
{
"name": "userName",
"type": ["null" ,"string"],
"avro.java.string": "String"
},
{
"name": "addressRef",
"default": null,
"type": ["null", {
"name": "addressRefRecord",
"type": "record",
"fields": [
{
"name": "addrRefId",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "addrType",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "addressLine1",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "addressLine2",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "city",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "province",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "country",
"type": ["null","string"],
"avro.java.string": "String"
},
{
"name": "postalCode",
"type": ["null","string"],
"avro.java.string": "String"
}
]
}
]
}
]
}
}
]
}
My JSON data that I intend to map to above schema looks like follows:
"dataRefs": [{
"addressRef": {
"addrRefId": "0",
"addrType": "ADDRESS",
"addressLine1": "DA 81",
"addressLine2": "",
"city": "Amsterdam",
"country": "Netherlands",
"postalCode": "xxxx LN",
"province": ""
},
"dataId": "0",
"email": "xyz#abc.com"
}],
This is how I was able to do so:
{
"name": "dataRefs",
"type": [
"null",
{
"type": "record",
"name": "dataRefsObject",
"fields": [
{
"name": "dataRefsArray",
"type": {
"type": "array",
"items": {
"name": "dataRef",
"type": "record",
"fields": [
{
"name": "dataId",
"type": ["null", "string"],
"avro.java.string": "String"
},
{
"name": "userName",
"type": [
"null",
"string"
],
"avro.java.string": "String"
},
....

How to convert Json Array to Avro Schema

Hey i am new to Avro Schema space, needed to convert Jason Array into Avro Schema.
Below Jason is kind of client which serviceName along-with enabler-
If Enabler is true means that particular service is taken by client
If Enabler is false means that particular service is not taken by client.
{
"clientName": "Haven",
"serviceDetailsList": [
{
"serviceName": "Service1",
"enabled": true
},
{
"serviceName": "Service2",
"enabled": true
},
{
"serviceName": "Service3",
"enabled": true
},
{
"serviceName": "Service4",
"enabled": false
},
{
"serviceName": "Service5",
"enabled": false
},
{
"serviceName": "Service6",
"enabled": true
}
]
}
I worked with below schema but not getting proper response.
"fields":[
{"name": "serviceName", "type": [ "Boolean", "false" ] , "aliases":[
"service1" ]
},
{"name": "serviceName", "type": [ "Boolean", "false" ] , "aliases":[
"service2" ]
}
]
Any help would be appreciated.
Thank you all of you,again i tried and able to get correct scheam. Correct Avro Schema is-
{
"name": "modelData",
"type": "record",
"namespace": "com.hi.model",
"fields": [
{
"name": "clientName",
"type": "string"
},
{
"name": "serviceDetailsList",
"type": {
"type": "array",
"items": {
"name": "serviceDetailsList_record",
"type": "record",
"fields": [
{
"name": "serviceName",
"type": "string"
},
{
"name": "enabled",
"type": "boolean"
}
]
}
}
}
]
}

Elastic - JSON Array nested in Array

I have to index a json to Elastic which look like the below format. My problem is that the key "variable" is array that contains json objects (I thought about "nested" datatype of Elastic) but some of those objects it's possible to contain nested json arrays inside them. (see variable CUSTOMERS).
POST /example_data/data {
"process_name": "TEST_PROCESS",
"process_version ": 0,
"process_id": "1111",
"activity_id": "111",
"name": "update_data",
"username": "testUser",
"datetime": "2018-01-01 10:00:00",
"variables": [{
"name": "ΒΑΝΚ",
"data_type": "STRING",
"value": "EUROBANK"
},{
"name": "CITY",
"data_type": "STRING",
"value": "LONDON"
}, {
"name": "CUSTOMERS",
"data_type": "ENTITY",
"value": [{
"variables": [{
"name": "CUSTOMER_NAME",
"data_type": "STRING",
"value": "JOHN"
}, {
"name": " CUSTOMER_CITY",
"data_type": "STRING",
"value": "LONDON"
}
]
}
]
}, {
"name": "CUSTOMERS",
"data_type": "ENTITY",
"value": [{
"variables": [{
"name": "CUSTOMER_NAME",
"data_type": "STRING",
"value": "ΑΘΗΝΑ"
}, {
"name": " CUSTOMER_CITY ",
"data_type": "STRING",
"value": "LIVERPOOL"
}, {
"name": " CUSTOMER_NUMBER",
"data_type": "STRING",
"value": "1234567890"
}
]
}
]
}
] }
When I'm trying to index it I get the following error
{ "error": {
"root_cause": [
{
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [variables.value] with an object mapping [variables.value]"
}
],
"type": "illegal_argument_exception",
"reason": "Can't merge a non object mapping [variables.value] with an object mapping [variables.value]" }, "status": 400 }
Mapping
{ "example_data": {
"mappings": {
"data": {
"properties": {
"activity_id": {
"type": "text"
},
"name": {
"type": "text"
},
"process_name": {
"type": "text"
},
"process_version": {
"type": "integer"
}
"process_id": {
"type": "text"
},
"datetime": {
"type": "date",
"format": "yyyy-MM-dd HH:mm:ss"
},
"username": {
"type": "text",
"analyzer": "greek"
},
"variables": {
"type": "nested",
"properties": {
"data_type": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"name": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"value": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
}
}
}
}
}
}}}
When I remove the variable CUSTOMERS that contains the array, then It works properly because there are only json objects.
Is there a way to handle that? Thanks in advance

Resources