Normalizing the dogs API - normalizr

I was looking to get some practice using Normalizer and though I would give a shot with the dogs API at https://dog.ceo/dog-api/documentation/
Listing all breeds looks like this
{
"message": {
"affenpinscher": [],
"african": [],
"airedale": [],
"akita": [],
"appenzeller": [],
"australian": [
"shepherd"
],
"basenji": [],
"beagle": [],
"bluetick": [],
"borzoi": [],
...
What should the normalized data structure look like and how would you use Normalizer to get that?
The docs work for their simple example but I want to know how to deal with in the wild APIs that you have no control over modifying.

Related

Some Nearby Places returning "ZERO_RESULTS" for android

It seems some of the place types such as (night_club/taxi_stand/gas_station) are returning:
{
"html_attributions" : [],
"results" : [],
"status" : "ZERO_RESULTS"
}
While others are having no issue at all
Here is an example for department store:
https://maps.googleapis.com/maps/api/place/nearbysearch/json?&location=32.5548071,74.7962474&rankby=distance&keyword=department_store&key=YOUR_API_KEY
The documentation states it is all supported:
https://developers.google.com/maps/documentation/places/web-service/supported_types
This has been marked as a duplicate of:
https://issuetracker.google.com/35824648

Elastic Search Shard/Routing

I have a multi-tenant system and I am trying to design ElasticSearch to support multi-tenancy. I've searched on the net but all post I've found does not specify in practice how to do it.
The basic idea is to have on each index, 1 shard per customer and use custom routing to query the customer dedicated shard. This is clear. Now, how can I implement this? How can create multiple shards per index specifying the "key value" in order to query that specific shard in future? Code example will be helpful.
Thank you so much.
I don't think this is the correct way to achieve multi-tenancy, not at the shard-level.
What do you want to achieve exactly? I'd assume that you want that different users (or, better, different roles) can access different portions of an index. In this case, you should have a look at document-level security permissions.
How to achieve this in practice? Let's say that you have an index named multitenants-index, and you have two tenants such that: (i) the first tenant can read/write only those documents having the field "tenant": 1, (ii) the second tenant can read/write only those documents having the field "tenant": 2. Then, you might create the following two roles:
POST /_xpack/security/role/first_tenant
{
"indices": [
{
"names": [ "multitenants-index" ],
"privileges": [ "read", "write" ],
"query": "{\"match\": {\"tenant\": 1}}"
}
]
}
POST /_xpack/security/role/second_tenant
{
"indices": [
{
"names": [ "multitenants-index" ],
"privileges": [ "read", "write" ],
"query": "{\"match\": {\"tenant\": 2}}"
}
]
}

Request permission with suggestion chips

I'm able to request permission for access to the user's name and precise location. Since this generates a question that can be answered yes or no, it would seem to be an ideal situation to display suggestion chips allowing a person to tap to agree instead of acknowledging out loud.
However, the following JSON doesn't seem to work. It continues to prompt for permission, but doesn't display the chips.
{
"speech": "PLACEHOLDER_FOR_PERMISSION",
"contextOut": [],
"data": {
"google": {
"expectUserResponse": true,
"isSsml": false,
"richResponse": {
"items": [
{
"simpleResponse": {
"textToSpeech": "PLACEHOLDER_FOR_PERMISSION"
}
}
],
"suggestions": [
{"title":"yes"},
{"title":"no"}
]
},
"noInputPrompts": [],
"systemIntent": {
"intent": "actions.intent.PERMISSION",
"data": {
"#type": "type.googleapis.com/google.actions.v2.PermissionValueSpec",
"optContext": "To raise you up",
"permissions": [
"NAME",
"DEVICE_PRECISE_LOCATION"
]
}
}
}
}
}
Is there any way to get the suggestion chips? Any better way to handle this?
At the moment there is not way to handle suggestion chips (per your example) BUT we are working on it and I hope that in a month we will have this ability.
Thank you for bring up this important use case.

How do you add a "PrivateIpAddresses" to a Network interface

I am looking for the output of the troposphere to look like this(json). I could not find any examples to point me in the right direction at all. And in the future if I come across similar issues, is there any documentation I should refer to in particular?
"NetworkInterfaces": [
{
"DeleteOnTermination": "true",
"Description": "Primary network interface",
"DeviceIndex": 0,
"SubnetId": "subnet-yolo",
"PrivateIpAddresses": [
{
"PrivateIpAddress": "xxx.xx.xx.xx",
"Primary": "true"
}
],
"GroupSet": [
"xxxxxx",
"yyyyyy"
]
}
]
Answer was pretty basic. First we need to make a sample_ip like so
sample_ip = template.add_parameter(ec2.PrivateIpAddressSpecification(
"PrivateIpAddress",
Primary="true",
PrivateIpAddress="172.168.1.1"
))
Then do this:
PrivateIpAddresses=[Ref(sample_ip)]
I'll keep this here in case some uber beginner like me is not able to do this on his/her own.

includeStats in neo4j.rb

I'm using neo4j.rb, and when I run
MATCH (a {name:'apple'}) SET a.flag = true
I'd like to get the response data, which would be along the lines of:
{
"results": [
{
"columns": [],
"data": [],
"stats": {
"contains_updates": true,
"nodes_created": 0,
"nodes_deleted": 0,
"properties_set": 1,
"relationships_created": 0,
"relationship_deleted": 0,
"labels_added": 0,
"labels_removed": 0,
"indexes_added": 0,
"indexes_removed": 0,
"constraints_added": 0,
"constraints_removed": 0
}
}
],
"errors": []
}
Instead, I get nothing--the object is blank, I suppose because I'm not asking for nodes to be returned, but want metadata on the query results.
There's a proposed solution here using py2neo (py2neo return number of nodes and relationships created), with includeStats: true, and I've also tried appending it to the address I'm using to run queries as ?includeStats=true, which I saw somewhere else and resulted in a server not available error (response code 302 / RuntimeError) for me. Is there any solution for this using neo4j.rb ?
Unfortunately we don't keep the metadata when returning results in the neo4j-core gem. It might be something that's easy to add. Perhaps you could create an issue:
https://github.com/neo4jrb/neo4j-core/issues
Pull requests are welcome, of course!

Resources