Unable to delete Apache Atlas Classification - apache-atlas

I have a list of Classifications & Sub-classifications in Apache Atlas. Want to delete them & create a new list.
All the other classifications are getting deleted but one of them with name "PII" giving following error when we select Delete Classification.
Error: Given type PII has references
When we do a search via Rest API using below URL:
http://ip.of.atlas:21000/api/atlas/v2/search/basic?classification=PII
Following Result comes:
{
"queryType": "BASIC",
"searchParameters": {
"classification": "PII",
"excludeDeletedEntities": false,
"includeClassificationAttributes": false,
"includeSubTypes": true,
"includeSubClassifications": true,
"limit": 100,
"offset": 0
},
"entities": [
{
"typeName": "hive_table",
"attributes": {
"owner": "nifi",
"createTime": 1557832055000,
"qualifiedName": "demo.test_table#demopilot",
"name": "test_table"
},
"guid": "ecb7bb24-bdde-448c-b718-07273e5ce572",
"status": "DELETED",
"displayText": "test_table",
"classificationNames": [
"PII"
],
"meaningNames": [],
"meanings": []
},
{
"typeName": "hive_table",
"attributes": {
"owner": "nifi",
"createTime": 1557832055000,
"qualifiedName": "demo.test_table#demopilot",
"name": "test_table"
},
"guid": "ed5a9284-c290-4431-ab76-27b820478e29",
"status": "DELETED",
"displayText": "test_table",
"classificationNames": [
"PII"
],
"meaningNames": [],
"meanings": []
},
{
"typeName": "hive_column",
"attributes": {
"owner": "nifi",
"qualifiedName": "demo.test_table.traffic_case#demopilot",
"name": "traffic_case"
},
"guid": "73f75a6c-9f4e-41f0-b0ef-6c05ca132639",
"status": "DELETED",
"displayText": "traffic_case",
"classificationNames": [
"PII"
],
"meaningNames": [],
"meanings": []
}
]
}
Questions:
1. Is there a API which help to delete all Classifications irrespective of whether they are attached to Entity or not?
2. Delete Single Classification forcefully with Classification Name or GUID?

Running below GET request:
http://ip.of.atlas:21000/api/atlas/v2/types/typedefs
& then Delete the guid attached to the typedefs

I tested it out and you could use below API to delete a tag:
curl -k -X DELETE --insecure --negotiate -u : --header \
''{"classificationDefs":[{"name":"PII","superTypes":[],"attributeDefs":[]}]}' \
'https://atlas-host:21443/api/atlas/v2/types/typedefs?type=classification'

Related

Option "wildcarded" for "jsonPropertyValueQuery" ctsquery causes the different results called via REST API or in Marklogic Query Console

We have local instance of Marklogic recently downloaded from docker hub with the following bash command:
docker run --name marklogic-test -d -it -p 8000:8000 -p 8001:8001 -p 8002:8002 \
-e MARKLOGIC_INIT=true \
-e MARKLOGIC_ADMIN_USERNAME=admin \
-e MARKLOGIC_ADMIN_PASSWORD='Areally!PowerfulPassword1337' \
marklogicdb/marklogic-db:10.0-9.4-centos-1.0.0-ea4
The "Documents" database contains only two documents:
sample1.json
{
"v1": "1234",
"v2": "ABCD",
"v3": "0123456789"
}
and sample2.json
{
"v1": "5678",
"v2": "EFGH",
"v3": "9876543210"
}
In case we will run the following XQuery in Query Console:
xquery version "1.0-ml";
let $query := cts:and-query((
cts:directory-query("/", "infinity"),
cts:json-property-value-query("v3", "01*", ("wildcarded", "whitespace-sensitive", "punctuation-sensitive"))
))
return (xdmp:to-json($query), cts:search(/,$query))
The result will be expected... It will return only one document:
{
"andQuery": {
"queries": [
{
"directoryQuery": {
"uris": [
"/"
],
"depth": "infinity"
}
},
{
"jsonPropertyValueQuery": {
"property": [
"v3"
],
"value": [
"01*"
],
"options": [
"punctuation-sensitive",
"whitespace-sensitive",
"wildcarded",
"lang=en"
]
}
}
]
}
}
json as
JSON
{
"v1": "1234",
"v2": "ABCD",
"v3": "0123456789"
}
But if I will do the REST API request:
curl --location --request POST 'http://localhost:18000/LATEST/search?format=json' --user 'admin:Areally!PowerfulPassword1337' --header 'Content-Type: application/json' --data-binary "#test_api.json"
where the test_api.json has the following content:
{
"search": {
"ctsquery": {
"andQuery": {
"queries": [
{
"directoryQuery": {
"uris": [
"/"
],
"depth": "1"
}
},
{
"jsonPropertyValueQuery": {
"property": [
"v3"
],
"value": [
"01*"
],
"options": [
"punctuation-sensitive",
"wildcarded",
"whitespace-sensitive",
"lang=en"
]
}
}
]
}
},
"options": {
"return-plan": false,
"return-metrics": true,
"return-facets": true,
"return-query": false,
"transform-results": {
"apply": "raw"
},
"page-length": 10
}
}
}
The answer is like that:
{
"snippet-format": "snippet",
"total": 2,
"start": 1,
"page-length": 10,
"results": [
{
"index": 1,
"uri": "/sample1.json",
"path": "fn:doc(\"/sample1.json\")",
"score": 0,
"confidence": 0,
"fitness": 0,
"href": "/v1/documents?uri=%2Fsample1.json",
"mimetype": "application/json",
"format": "json",
"matches": [
{
"path": "fn:doc(\"/sample1.json\")/object-node()",
"match-text": [
"1234 ABCD 0123456789"
]
}
]
},
{
"index": 2,
"uri": "/sample2.json",
"path": "fn:doc(\"/sample2.json\")",
"score": 0,
"confidence": 0,
"fitness": 0,
"href": "/v1/documents?uri=%2Fsample2.json",
"mimetype": "application/json",
"format": "json",
"matches": [
{
"path": "fn:doc(\"/sample2.json\")/object-node()",
"match-text": [
"5678 EFGH 9876543210"
]
}
]
}
],
"metrics": {
"query-resolution-time": "PT0.000624S",
"snippet-resolution-time": "PT0.005684S",
"total-time": "PT0.00713S"
}
}
For some reason both documents are returned as result!
Even though "confidence" is 0.
How to understand that behavior of MarkLogic searching engine?
Is it a bug of Marklogic REST API or is there something we are missing?
In Query Console, look at the difference when applying the "filtered" vs. "unfiltered" option to your search.
MarkLogic REST API is an "unfiltered" query.
cts:search() by default is a "filtered" query.
A filtered search (the default). Filtered searches eliminate any false-positive matches and properly resolve cases where there are multiple candidate matches within the same fragment. Filtered search results fully satisfy the specified cts:query.
https://docs.marklogic.com/guide/performance/unfiltered#id_89797
An unfiltered search omits the filtering step, which validates whether each candidate fragment result actually meets the search criteria. Unfiltered searches, therefore, are guaranteed to be fast, while filtered searches are guaranteed to be accurate. By default, searches are filtered; you must specify the "unfiltered" option to cts:search to return an unfiltered search.

Getting started with KrakenD

I need some beginner help to KrakenD. I am running it on Ubuntu. The config is provided below.
I am able to reach the /healthz API without problem.
My challenge is that the /hello path returns error 500. I want this path to redirect to a Quarkus app that runs at http://getting-started36-getting-going.apps.bamboutos.hostname.us/.
Why is this not working? If I modify the /hello backend and use a fake host, I get the exacts ame result. This suggests that KrakendD is not even trying to connect to the backend.
In logs, KrakendD is saying:
Error #01: invalid character 'H' looking for beginning of value
kraken.json:
{
"version": 2,
"port": 9080,
"extra_config": {
"github_com/devopsfaith/krakend-gologging": {
"level": "DEBUG",
"prefix": "[KRAKEND]",
"syslog": false,
"stdout": true,
"format": "default"
}
},
"timeout": "3000ms",
"cache_ttl": "300s",
"output_encoding": "json",
"name": "KrakenD API Gateway Service",
"endpoints": [
{
"endpoint": "/healthz",
"extra_config": {
"github.com/devopsfaith/krakend/proxy": {
"static": {
"data": { "status": "OK"},
"strategy": "always"
}
}
},
"backend": [
{
"url_pattern": "/",
"host": ["http://fake-backend"]
}
]
},
{
"endpoint": "/hello",
"extra_config": {},
"backend": [
{
"url_pattern": "/hello",
"method": "GET",
"host": [
"http://getting-started36-getting-going.apps.bamboutos.hostname.us/"
]
}
]
}
]
}
What am I missing?
add "encoding": "string" to the backend section.
"backend": [
{
"url_pattern": "/hello",
"method": "GET",
"encoding": "string" ,
"host": [
"http://getting-started36-getting-going.apps.bamboutos.hostname.us/"
]
}
]

How to delete user by email id using azure SCIM api in databricks?

I need to know if there is a way to delete a user from databricks using email only using SCIM api? As of now I can see it can only delete user by ID which means I need to first retrive the ID of the user and then use it to delete.
I am using this api from powershell to delete users by email.
https://learn.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/scim/scim-users
If you look into the documentation for Get Users command of SCIM Users REST API, you can see that you can specify the filtering condition for it. For example, to find specific user, you can filter on the userName attribute, like this:
GET /api/2.0/preview/scim/v2/Users?filter=userName+eq+example#databricks.com HTTP/1.1
Host: <databricks-instance>
Accept: application/scim+json
Authorization: Bearer dapi48…a6138b
it will return a list of items in the Resources section, from which you can extract user ID that you can use for delete operation:
{
"totalResults": 1,
"startIndex": 1,
"itemsPerPage": 1,
"schemas": [
"urn:ietf:params:scim:api:messages:2.0:ListResponse"
],
"Resources": [
{
"id": "8679504224234906",
"userName": "example#databricks.com",
"emails": [
{
"type": "work",
"value": "example#databricks.com",
"primary": true
}
],
"entitlements": [
{
"value": "allow-cluster-create"
},
{
"value": "databricks-sql-access"
},
{
"value": "workspace-access"
}
],
"displayName": "User 1",
"name": {
"familyName": "User",
"givenName": "1"
},
"externalId": "12413",
"active": true,
"groups": [
{
"display": "123",
"type": "direct",
"value": "13223",
"$ref": "Groups/13223"
}
]
}
]
}

How to make a post API for mongodb with loopback

I am newbie with mongodb and loopback. I want to send and save data from my app to database. how can I do that?
Update
shops model:
{
"shopname": "string",
"tel": "string",
"latlng": "string",
"address": "string",
"id": "string",
"personId": "string"
}
CURL:
curl -X POST --header 'Content-Type: application/json' --header 'Accept: application/json' -d '{ \
"shopname": "spring", \
"tel": "12345678", \
"latlng": "52.1106986,21.7768998", \
"address": "05-319 Skwarne, Poland" \
}' 'http://localhost:3000/api/shops'
Now what should I write in shops.js to give an api for using in app to send data to database ?
'use strict';
module.exports = function(Shops) {
};
you should have provided more info about the steps you have already done.
let me begin with the first step:
download and install mongodb on your server: link
after running mongodb, add your desired database info to datasources.json file. e.g.
{
"db": {
"name": "db",
"connector": "memory"
},
"shopDB": {
"host": "localhost",
"port": 27017,
"url": "mongodb://localhost:27017/shopDB",
"database": "shopDB",
"password": "",
"name": "shopDB",
"user": "",
"connector": "mongodb"
}
}
add loopback-connector-mongodb to your project via npm.
now define your model(you can utilize loopback's user friendly command line interface to do so. call command "slc loopback:model" in your projects root folder)
after you finish the step 4, loopback will create 2files for you: shop.js and shop.json => these files are located in your projectFolder/common/models/ directory. note that it's a good practice to follow the loopback's convention in naming models and name your model in singular form(shop). (it uses the plural forms of the model names in other parts of the project). your shop.json should look like the below code:
{
"name": "shop",
"plural": "shops",
"base": "PersistedModel",
"idInjection": true,
"options": {
"validateUpsert": true
},
"properties": {
"shopname": {
"type": "string",
"required": true
},
"tel": {
"type": "string",
"required": true
},
"latlng": {
"type": "string",
"required": true
},
"address": {
"type": "string"
},
"personId": {
"type": "string",
"required": true
}
},
"validations": [],
"relations": {},
"acls": [],
"methods": {}
}
now you can post your shop json to http://localhost:3000/api/shops/ . note that our shop model inherits from PersistedModel base model and has some built-in functions to do crud operations. and if you want just create some shop instances in your db, you won't need to add anything to your shop.js file!

How to set review for revision using Gerrit REST API

I'm trying to setup Teamcity building and verifying patchsets from Gerrit. The last step should set Verified to -1 if build failed. I'm playing around with Gerrit REST API and I think I found a proper command:
https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#set-review
The documentation says:
As response a ReviewInfo entity is returned that describes the applied
labels.
My request looks like this:
POST <gerrit-url>/a/changes/I696f00f4968fcb35fa614ce6325499aa15367150/revisions/current/review
{
"message": "Build failed",
"labels": {
"Verified": -1
}
}
As a response I get full revision info:
{
"id": "dev_test~master~<change-id>",
"project": "dev_test",
"branch": "master",
"hashtags": [],
"change_id": "<change-id>",
"subject": "a test",
"status": "NEW",
"created": "2017-04-03 07:53:19.000000000",
"updated": "2017-04-04 08:47:34.000000000",
"submit_type": "MERGE_IF_NECESSARY",
"mergeable": true,
"insertions": 133,
"deletions": 7,
"unresolved_comment_count": 0,
"_number": 381,
"owner": {
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>",
},
"labels": {
"Code-Review": {
"all": [
{
"value": 1,
"date": "2017-04-04 08:47:34.000000000",
"permitted_voting_range": {
"min": -2,
"max": 2
},
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
],
"values": {
"-2": "This shall not be merged",
"-1": "I would prefer this is not merged as is",
" 0": "No score",
"+1": "Looks good to me, but someone else must approve",
"+2": "Looks good to me, approved"
},
"default_value": 0
},
"Verified": {
"all": [
{
"value": 0,
"permitted_voting_range": {
"min": -1,
"max": 1
},
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
],
"values": {
"-1": "Fails",
" 0": "No score",
"+1": "Verified"
},
"default_value": 0
}
},
"permitted_labels": {},
"removable_reviewers": [],
"reviewers": {
"REVIEWER": [
{
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
}
]
},
"current_revision": "913330441711b067899a664a60c78be518e547b4",
"revisions": {
"913330441711b067899a664a60c78be518e547b4": {
"kind": "REWORK",
"_number": 6,
"created": "2017-04-03 14:08:14.000000000",
"uploader": {
"_account_id": 4,
"name": "<my-name>",
"email": "<my-email>",
"username": "<my-username>"
},
"ref": "refs/changes/81/381/6",
"fetch": {
"ssh": {
"url": "ssh://<url>",
"ref": "refs/changes/81/381/6"
},
"http": {
"url": "http://<url>",
"ref": "refs/changes/81/381/6"
}
}
}
}
}
It's not affected by request. Same response is returned when I send request using GET method or using POST method with invalid JSON in body(!)
Gerrit version is: 2.13.6-3008-gcdc381e
Do I something wrong?
PS. Here is similar question, but it isn't helpful: Gerrit set-review api doesn't work
EDIT:
It seems that I getting response from GET request not POST
I figured it out. It's not gerrit problem. I used http request and our server redirected to https with 301 which the Postman fallowed and returned response for GET request.