Google FHIR API - Patient $everything - google-cloud-platform

I am trying to use this api . https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID/$everything
I am getting this error
{
"issue": [
{
"code": "not-supported",
"details": {
"text": "bad_resource_type"
},
"diagnostics": "unsupported resource type",
"severity": "error"
}
],
"resourceType": "OperationOutcome"
}

The correct command according to the documentation should be:
curl -X GET \
-H "Authorization: Bearer "$(gcloud auth print-access-token) \
"https://healthcare.googleapis.com/v1beta1/projects/PROJECT_ID/locations/REGION/datasets/DATASET_ID/fhirStores/FHIR_STORE_ID/fhir/Patient/PATIENT_ID/\$everything"
Notice that a "\" sign is missing before the $everything".

Related

Google Cloud Armor doesn't seam to interpret reCaptcha enterprise score

This is follow up question to another one about reCaptcha and GCA.
I have GKE applications in following setup:
front app works on example.com
backend app works on api.example.com
I expose those loads via Ingress and all looks cool. I want to protect application with Cloud Armor. I added annotation to api service. I can confirm that if policy has just one rule "deny all IPs" I cannot reach backend endpoints and if I change rule to "allow all IPs" I can. So GCA itself works ok.
I tried to connect reCaptcha Enterprise and interpret its score with Google Cloud Armor but I cannot make it work. I created following rules but whatever values I add token.recaptcha.score doesn't seem to be interpreted at all.
I have 3 following rules:
priority: 500, expression: "request.method == 'OPTIONS'"
priority: 1000, expression: "token.recaptcha.score > 0.1"
priority: 2147483647, expression: deny(403) from *.
I can see that OPTIONS passes:
{
"insertId": "1xxxr",
"jsonPayload": {
"#type": "type.googleapis.com/google.cloud.loadbalancing.type.LoadBalancerLogEntry",
"enforcedSecurityPolicy": {
"priority": 500,
"configuredAction": "ALLOW",
"outcome": "ACCEPT",
"name": "login-security-policy"
},
"statusDetails": "response_sent_by_backend"
},
"httpRequest": {
"requestMethod": "OPTIONS",
"requestUrl": "https://api.example.com/v1/graphs?pageSize=10&orderBy=created_at%20desc&key=AxxxE",
"requestSize": "97",
"status": 200,
"responseSize": "367",
"userAgent": "XXX",
"remoteIp": "XX.XX.XX.XX",
"referer": "https://example.com/",
"serverIp": "10.10.0.33",
"latency": "0.126041s"
},
"resource": {
"type": "http_load_balancer",
"labels": {
"project_id": "xxx",
"zone": "global",
"url_map_name": "k8s2-um-dxxxd-default-main-ixxxq",
"backend_service_name": "k8s-be-3xxx9--9xxx9",
"target_proxy_name": "k8s2-ts-dxxxd-default-main-ixxxq",
"forwarding_rule_name": "k8s2-fs-dxxxd-default-main-ixxxq"
}
},
"timestamp": "2021-12-21T18:28:42.103879Z",
"severity": "INFO",
"logName": "projects/xxx/logs/requests",
"trace": "projects/xxx/traces/3xxx2",
"receiveTimestamp": "2021-12-21T18:28:43.228371341Z",
"spanId": "5xxx0"
}
but then GET doesn't:
{
"insertId": "1xxxr",
"jsonPayload": {
"statusDetails": "denied_by_security_policy",
"enforcedSecurityPolicy": {
"outcome": "DENY",
"configuredAction": "DENY",
"name": "login-security-policy",
"priority": 2147483647
},
"#type": "type.googleapis.com/google.cloud.loadbalancing.type.LoadBalancerLogEntry"
},
"httpRequest": {
"requestMethod": "GET",
"requestUrl": "https://api.example.com/v1/graphs?pageSize=10&orderBy=created_at%20desc&key=AxxxE",
"requestSize": "1291",
"status": 403,
"responseSize": "194",
"userAgent": "XXX",
"remoteIp": "XX.XX.XX.XX",
"referer": "https://example.com/",
"latency": "0.221476s"
},
"resource": {
"type": "http_load_balancer",
"labels": {
"project_id": "xxx",
"target_proxy_name": "k8s2-ts-dxxxd-default-main-ixxxq",
"forwarding_rule_name": "k8s2-fs-dxxxd-default-main-ixxxq",
"zone": "global",
"url_map_name": "k8s2-um-dxxxd-default-main-ixxxq",
"backend_service_name": "k8s-be-3xxx9--9xxx9"
}
},
"timestamp": "2021-12-21T18:28:42.254613Z",
"severity": "WARNING",
"logName": "projects/xxx/logs/requests",
"trace": "projects/xxx/traces/5xxx0",
"receiveTimestamp": "2021-12-21T18:28:43.228371341Z",
"spanId": "axxxb"
}
Here is also this GET request exported from browser:
curl 'https://api.example.com/v1/graphs?pageSize=10&orderBy=created_at%20desc&key=AxxxE' \
-H 'authority: api.example.com' \
-H 'pragma: no-cache' \
-H 'cache-control: no-cache' \
-H 'accept: application/json, text/plain, */*' \
-H 'authorization: Bearer exxxw' \
-H 'x-recaptcha-token: Axxxo' \
-H 'user-agent: XXX' \
-H 'origin: https://example.com' \
-H 'sec-fetch-site: same-site' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://example.com/' \
--compressed
reCAPTCHA WAF is a new feature reCAPTCHA enterprise have. It put reCAPTCHA at edge layer, protecting web application in WAF(Web application Firewall), before hitting the application server.
recaptcha waf token is different from the normal recaptcha enterprise token.
Make sure reCAPTCHA waf token is visible to Cloud Armor.
If you are using the session-token case, it will be the cookie, should automatically visible to Cloud Armor. If you are using the action-token case, make sure the token is attached at the request header, see the integration guide for action-token.

Invalid JSON payload received. Unknown name \"row\" at 'payload': Cannot find field on google automl api

I am trying to implement google automl api:
https://cloud.google.com/automl-tables/docs/predict
The api docs says I need to post data in following format:
{
"payload": {
"row": {
"values": [value1, value2,...]
}
}
}
But when I to post data in same format I get the following error:
{
"error": {
"code": 400,
"message": "Invalid JSON payload received. Unknown name \"row\" at 'payload': Cannot find field.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "payload",
"description": "Invalid JSON payload received. Unknown name \"row\" at 'payload': Cannot find field."
}
]
}
]
}
}
Here is my curl request:
curl --location --request POST 'https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/TBLID:predict' \
--header 'Content-Type: application/json; charset=utf-8;' \
--header 'Accept-Charset: utf-8' \
--header 'Authorization: Bearer token here' \
--data-raw '{
"payload": {
"row": {
"values": [
"",
"4.900000",
""
]
}
}
}'
I am not sure what is causing this error.
Can anyone help with this problem thanks
I have a project with AutoML tables and this is an example prediction request sent in which works fine and returns results without error:
{
"payload": {
"row": {
"values": [
"2",
"test text",
"test text",
"21",
"0",
"0",
"test text",
"10",
"",
"S"
]
}
}
}
If you're not sure how to submit data or you are getting errors, go to your project in the console and to your AutoML Tables model and click "Test and Use". Then, follow these directions for getting an online prediction from console. Pay attention to the JSON Code View which will give you the exact input and let you test your JSON input as well.
To test, I submitted the following curl request (with some identifying characters changed)
curl -X POST \
-H "Authorization: Bearer "$(gcloud auth application-default print-access-token) \
-H "Content-Type: application/json; charset=utf-8" \
-d #request.json \
https://automl.googleapis.com/v1beta1/projects/this-isnt-a-real-project-id/locations/us-central1/models/TBL123451234512345:predict
My request.json file in the same directory that I sent the request from was:
{
"payload": {
"row": {
"values": [
"yes",
"-1",
"primary",
"jul",
"51",
"0",
"yes",
"no",
"88",
"cellular",
"blue-collar",
"unknown",
"10",
"620",
"married"
]
}
}
}
The response was:
{
"payload": [
{
"tables": {
"score": 0.9999906,
"value": "no"
}
},
{
"tables": {
"score": 9.42341e-06,
"value": "yes"
}
}
]
}
I also repeated this same request in postman successfully below:
curl --location --request POST 'https://automl.googleapis.com/v1beta1/projects/this-isnt-a-real-project-id/locations/us-central1/models/TBL123451234512345:predict' \
--header 'Accept-Charset: utf-8' \
--header 'Authorization: Bearer abcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcdabcd' \
--header 'Content-Type: application/json' \
--data-raw '{
"payload": {
"row": {
"values": [
"yes",
"-1",
"primary",
"jul",
"51",
"0",
"yes",
"no",
"88",
"cellular",
"blue-collar",
"unknown",
"10",
"620",
"married"
]
}
}
}'
I replicated the Quickstart and I did some successful curl requests and your issue seems to be related to the format of your json request; therefore, I recommend the following tests:
Remove the line breaks from your json, and make the request again:
curl --location --request POST 'https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/TBLID:predict' \
--header 'Content-Type: application/json; charset=utf-8;' \
--header 'Accept-Charset: utf-8' \
--header 'Authorization: Bearer token-here' \
--data-raw '{ "payload": { "row": { "values": [ "", "4.900000", "" ] } } }'
Save the json in a file and make the request again:
curl --location --request POST 'https://automl.googleapis.com/v1/projects/project-id/locations/us-central1/models/TBLID:predict' \
--header 'Content-Type: application/json; charset=utf-8;' \
--header 'Accept-Charset: utf-8' \
--header 'Authorization: Bearer token-here' \
-d #request.json
If after performing them you still have the issue, I recommend you contact the GCP support so they can analyze your issue within your project.

Google Recommendations AI sample rest request

I am trying to build a simple recommendation engine using Google Recommendations AI and referring their official documentation. currently I have build a simple curl request and whenever I execute it i get different errors, but all the time error code is 404,i have given sample curl request i have sent
DATA='{
"id": "1234",
"category_hierarchies": [ { "categories": [ "athletic wear", "shoes" ] } ],
"title": "ABC sneakers",
"description": "Sneakers for the rest of us",
"language_code": "en",
"tags": [ ],
"product_metadata": {
"exact_price": {
"display_price": 99.98,
"original_price": 111.99 },
"costs": {
"manufacturing": 35.99,
"other": 20
},
"currency_code": "USD",
"canonical_product_uri": "https://www.example.com/products/1234",
"images": [ ]
}
}'
curl -X POST \
-H "Authorization: Bearer access toke is given here" \
-H "Content-Type: application/json; charset=utf-8" \
-d "${DATA}" \
"https://recommendationengine.googleapis.com/v1beta1/projects/[PROJECT_ID]/locations/global/catalogs/default_catalog/catalogItems:import"
Many times i get as string lent is not specified or sometimes blank 404 error message, Any elp would be appreciated.
Thank you

How to use Google Data Prep API using Python

Google Just launched the new API. Link is here.
I want to know what is the host in this case as they are using example.com and using the port 3005.
I am also following this article. But this does not provide example code.
If you open the Dataprep Console and navigate to Settings > Access Tokens you can click on Generate New Token. This will bring up the token, that you can copy to clipboard, but also the instructions on which base endpoint to use:
Then, clicking on a particular Recipe (see image below) will modify the browser URL to be in the form of:
https://clouddataprep.com/flows/<FLOW_ID>?recipe=<RECIPE_ID>&tab=recipe
We'll keep RECIPE_ID> so that our request body (dataprep-request.json) is something like this:
{
"wrangledDataset": {
"id": <RECIPE_ID>
}
}
Then, we can call JobGroups Create:
curl https://api.clouddataprep.com/v4/jobGroups \
-X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d #dataprep-request.json
The response will be similar to this output (I used python3 -m json.tool to pretty print the JSON):
{
"sessionId": "<SESSION_ID>",
"reason": "JobStarted",
"jobGraph": {
"vertices": [
4479390,
4479391
],
"edges": [
{
"source": 4479390,
"target": 4479391
}
]
},
"id": <JOB_GROUP_ID>,
"jobs": {
"data": [
{
"id": 4479390
},
{
"id": 4479391
}
]
}
}
Now, with the retrieved <JOB_GROUP_ID> we can use the JobGroups Get endpoint:
curl https://api.clouddataprep.com/v4/jobGroups/<JOB_GROUP_ID> \
-H "Authorization: Bearer $TOKEN"
Response:
{
"id": <JOB_GROUP_ID>,
"name": null,
"description": null,
"ranfrom": "ui",
"ranfor": "recipe",
"status": "InProgress",
"profilingEnabled": true,
"runParameterReferenceDate": "2019-12-08T21:49:33.000Z",
"createdAt": "2019-12-08T21:49:35.000Z",
"updatedAt": "2019-12-08T21:49:36.000Z",
"workspace": {
"id": REDACTED
},
"creator": {
"id": REDACTED
},
"updater": {
"id": REDACTED
},
"snapshot": {
"id": 4226057
},
"wrangledDataset": {
"id": <RECIPE_ID>
},
"flowRun": null
}

Go-CD: How to use API to trigger a pipeline?

Is there an API can be used to trigger a pipeline, I did not find one in the API manual. Or, is there any other way I can trigger a pipeline using linux command?
Thanks
link to the docs: https://api.gocd.org/current/#scheduling-pipelines
POST /go/api/pipelines/:pipeline_name/schedule
in the request you can override the environmental variables, the material to use and choose to update the material before the start.
command example as taken from the documentation:
$ curl 'https://ci.example.com/go/api/pipelines/pipeline1/schedule' \
-u 'username:password' \
-H 'Accept: application/vnd.go.cd.v1+json' \
-H 'Content-Type: application/json' \
-X POST \
-d '{
"environment_variables": [
{
"name": "USERNAME",
"secure": false,
"value": "bob"
},
{
"name": "SSH_PASSPHRASE",
"value": "some passphrase",
"secure": true,
},
{
"name": "PASSWORD",
"encrypted_value": "YEepp1G0C05SpP0fcp4Jh+kPmWwXH5Nq",
"secure": true,
}
],
"materials": [
{
"fingerprint": "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
"revision": "123"
},
{
"fingerprint": "7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
"revision": "1058e75b18e8a645dd71702851994a010789f450"
}
],
"update_materials_before_scheduling": true
}'
/go/api/pipelines/${pipelineName}/schedule works