Google People API - Is it possible to get custom fields? - google-api

I need to import google contacts to my application. For that I try to use the Google People API but I didn't find an option to get the contacts custom fields.
Is it possible to get contact custom fields with the new Google People API?
Should I use the old Google Contacts API for that?
Thanks!

Request the userDefined projection with your personFields.
String url = "https://people.googleapis.com/v1/people/me/connections" +
"?personFields=names,emailAddresses,userDefined";
The response looks like this:
"userDefined": [
{
"metadata": {
"primary": true,
"source": {
"type": "CONTACT",
"id": "5629e24b082d1a66"
}
},
"key": "label1",
"value": "foo"
},
{
"metadata": {
"source": {
"type": "CONTACT",
"id": "5629e24b082d1a66"
}
},
"key": "label2",
"value": "bar"
}
]
For more details, see https://developers.google.com/people/api/rest/v1/people#Person.UserDefined
You can also update custom fields even though the documentation does not currently list userDefined as a valid field for updatePersonFields as the field mask.
https://developers.google.com/people/api/rest/v1/people/updateContact

Related

What `eventCount` property means in data from Microsoft Store analytics API?

I am trying to get some info about errors of my desktop app from Microsoft Store analytics API. This is the response that I get from API:
{
"Value": [
{
"date": "2021-05-27",
"applicationId": "myid",
"applicationName": "myapp",
"failureName": "MOAPPLICATION_HANG_cfffffff_0EB8BD08.myapp!HANG_QUIESCE",
"eventType": "hang",
"deviceCount": 1423.0,
"eventCount": 1244.41342561402
},
{
"date": "2021-05-25",
"applicationId": "myid",
"applicationName": "myapp",
"failureName": "MOAPPLICATION_HANG_cfffffff_0EB8BD08.myapp!HANG_QUIESCE",
"eventType": "hang",
"deviceCount": 1468.0,
"eventCount": 1242.87238240919
},
{
"date": "2021-05-26",
"applicationId": "myid",
"applicationName": "myapp",
"failureName": "MOAPPLICATION_HANG_cfffffff_0EB8BD08.myapp!HANG_QUIESCE",
"eventType": "hang",
"deviceCount": 1480.0,
"eventCount": 1297.92338878456
}
],
"TotalCount": 3
}
Among other things, I want to know how many errors of each type were in specified period. I hoped that field eventCount would represent this info but as I can see it's not an integer in my case. Also in Microsoft docs I can see the same thing in example.
I got two questions:
Which metric eventCount field represents?
How can I get number of errors using this API?

How to patch property of list in nested object with condition for restful api

How should i design a Restful API for PATCH operation that support update some property in the a list with condition?
say i have following json model:
{
"key1": "value",
"key2": "value",
"list": [
{
"property": "someValue",
"toBePatched": "value"
},
{
"property": "otherValue",
"toBePatched": "value"
}
]
}
I need to patch the "toBePatched" property in the list when the "property" equals to "someValue". By looking at the json patch here, i think it is a good way to go, but i dont think the json pointer supports the query? how should i define a path that supports "/list/property=someValue/toBePatch"?
One stupid way to do it is to pass it as query parameter to the api, and have some logic around it, but i dont think thats a standard way to do it.
[
{ "op": "test", "path": "/list/0/property", "value": "someValue"},
{ "op": "test", "path": "/list/0/toBePatched", "value": "value"},
{ "op": "replace", "path": "/list/0/toBePatched", "value": "the-new-value"}
]
test is important, it lets you verify that the server hasn't change the part of the document that you are intending to change. See section 5 on Error Handling for details.

How can I manage sitemaps in Kentico Cloud?

There used to be sitemaps functionality but it got deprecated. Taxonomies are suggested as a replacement but when I request items from the API, the taxonomy elements lack the hierarchical structure. How do I search for an item that represents a parent page in website structure? Thank you.
You can still do that with Delivery API. First, you need to create and and organize your taxonomy group the same way you would organize your sitemap. Consider following sitemap as an example:
Home
About
Our team
Management
Contact us
Mission&Values
This is what the taxonomies would look like in Kentico Cloud:
Models for your items need to be created with taxonomy element, that would serve as a sitemap location selector. When you retrieve this element from the item, it will give you a list of terms that the item is associated with. If you tick two terms with the item (Contact us, Our team), this is what the element would look like in the API:
{
"item": {
"system": {
"id": "8a9e7010-c79b-41c5-a0bc-4f20c9c233b8",
"name": "Example item - contact form",
"codename": "example_item___contact_form",
"language": "default",
"type": "example_content_model",
"sitemap_locations": [],
"last_modified": "2019-05-13T08:20:50.3173519Z"
},
"elements": {
"sitemap": {
"type": "taxonomy",
"name": "Sitemap",
"taxonomy_group": "sitemap",
"value": [
{
"name": "Contact Us",
"codename": "contact_us"
},
{
"name": "Our team",
"codename": "our_team"
}
]
}
}
},
"modular_content": {}
}
As you can see you get information about taxonomy group codename and a flat list of name and codename pairs of each ticked term. To get the hierarchical structure, you need to make second call to retrieve the taxonomy group, which will yield following:
{
"system": {
"id": "0b4e3da2-8699-4b4d-961c-1fe912c91570",
"name": "Sitemap",
"codename": "sitemap",
"last_modified": "2019-05-13T08:01:34.6109452Z"
},
"terms": [
{
"name": "Home",
"codename": "home",
"terms": []
},
{
"name": "About",
"codename": "about",
"terms": [
{
"name": "Our team",
"codename": "our_team",
"terms": [
{
"name": "Management",
"codename": "management",
"terms": []
},
{
"name": "Contact Us",
"codename": "contact_us",
"terms": []
}
]
},
{
"name": "Mission & Values",
"codename": "mission___values",
"terms": []
}
]
}
]
}
Which reflects needed hierarchy. You can compare the codenames you got from your item to the position of the taxonomy term in your group - to get the parent taxonomy term just get the parent JSON node. If you need to figure out the parent item itself, you can call Delivery API again and use one of the array filters to get all the items marked with the parent sitemap location.

Jira Trigger plugin for Jenkins: Obtaining Value from issue object

I'm trying to set up some automation using Jenkins and Jira Trigger plugin for Jenkins. I've set up a web hook at Jira side which is able to invoke build on Jenkins as desired.
I've a trouble with obtaining value for a custom field from incoming Jira request.
I'm trying to use "Issue Attribute Path" feature and I've also referred to post (How to use the 'Issue attribute path' in the parameter mapping of jenkins-trigger-plugin)
Howevevr I'm still unable to get value for custom fields customfield_10010, customfield_10011. I've tried with mapping like fields.customfield_10010, fields.customfield_10010.value, fields.customfield_10010.0.value,customfield_10010.0.value and similar combinations. I'm able to get value for other standard fields as suggested in plugin help. ex: status.name, description etc.
I could not get any clue from Jira documentation site either.
Parts of incoming json data is below for easy reference.
"issue": {
"id": "1000x",
"self": "http://localhost:3080/rest/api/2/issue/10007",
"key": "ABC-2",
"fields": {
"issuetype": {
..
},
"parent": {
..
},
"components": [
],
"timespent": null,
"timeoriginalestimate": 28800,
"description": ".....",
"project": {
..
},
"customfield_10010": [
{
"self": "http://localhost:3080/rest/api/2/customFieldOption/10019",
"value": "ABC-Custom 1",
"id": "10019"
}
],
"fixVersions": [
],
"customfield_10011": [
{
"self": "http://localhost:3080/rest/api/2/customFieldOption/10021",
"value": "ABC-Custom 2",
"id": "10021"
}
],
.....
....
....
}
}
You can get the value of a custom field with the following syntax:
fields.find { it.id == "customfield_10010" }.value
I had the same problem and found this solution here:
https://issues.jenkins-ci.org/browse/JENKINS-13216

Can Django REST Framework indicate readonly fields to client?

This is a newbie question. I see that the browsable API for Django rest framework is able to detect readonly fields defined in my serializer and exclude them from the HTML form that is presented to the user for PUT/POST operations.
What is the mechanism used here and can I use the same to indicate readonly fields to the remote client? I don't see any difference in the format between readonly fields and writable fields in the JSON object itself, so I'm guessing that there is some metadata involved but I couldn't find anything in the documentation.
I'm using Django version 1.7 and django-rest-framework version 3.1.3.
You should send an OPTION request to Django REST framework to get an insight of the expected content - see the option button on the browsable interface.
See the id field under the following sample:
{
"name": "Task List",
"description": "",
"renders": [
"application/json",
"text/html"
],
"parses": [
"application/json",
"application/x-www-form-urlencoded",
"multipart/form-data"
],
"actions": {
"POST": {
"id": {
"type": "integer",
"required": false,
"read_only": true,
"label": "ID"
},
"name": {
"type": "string",
"required": true,
"read_only": false,
"label": "Name",
"max_length": 64
},
"owner": {
"type": "field",
"required": true,
"read_only": false,
"label": "Owner",
"choices": [
{
"display_name": "admin",
"value": "admin"
},
{
"display_name": "cody",
"value": "cody"
}
]
}
}
}
}
U should use django-swagger, it is an app to document django rest framework APIs.
In you serializer field, you can set a help text, you can use it to mark as read only field the your client should read that on APIs document.

Resources