Github hook for pull_request sent to AmazonSNS - github

I've seen (and tested) GitHub's integration with Amazon SNS. But, there doesn't appear to be a way to specify what events you want to hook (at least in the UI). Push works fine. Is there a way to hook a pull request and have it push an event to an sns topic?
Note: if there is documentation for this, I have not be able to find it. Please include a link with your answer.

Complementing the OP's answer:
you need to get the amazon sns integration hook id through the list hooks endpoint (GET /repos/:owner/:repo/hooks)
once you have the corresponding id, you need to add/remove supported events through the edit a hook endpoint (PATCH /repos/:owner/:repo/hooks/:id)
I personally didn't know that integrations were treated as "usual" webhooks.

FYI, for future readers, I think I found my own answer. I found the following:
{
"name": "amazonsns",
"events": [
"push"
],
"supported_events": [
"commit_comment",
"create",
"delete",
"download",
"follow",
"fork",
"fork_apply",
"gist",
"gollum",
"issue_comment",
"issues",
"member",
"public",
"pull_request",
"pull_request_review_comment",
"push",
"status",
"team_add",
"watch"
],
"schema": [
[
"string",
"aws_key"
],
[
"string",
"aws_secret"
],
[
"string",
"sns_topic"
],
[
"string",
"sqs_queue"
],
[
"password",
"aws_secret"
]
]
}
This was at: https://api.github.com/hooks

Related

Add/remove pipeline checks using REST API

I have a requirement to dynamically add/remove or enable disable approval and checks at azure DevOps pipeline environment.
Is there a rest api for this?
Is there a rest api for this?
Yes, it has. BUT, as what the #Krysztof said, we haven't provide such api documents to public as of today. This is because what you are looking for is one feature (configure Check and approval from environments ) that only support for YAML pipeline, and until now, we are developing but does not publish the corresponding rest api (for YAML) docs.
But, as work around, you can catch these apis from F12. Just do action from UI, then capture and analyze corresponds api records to found out what you are expecting.
Here I make the summary to you.
The api that used to add/delete approval and check to environment is:
https://dev.azure.com/{org name}/{project name}/_apis/pipelines/checks/configurations
The corresponding api method for add or delete is Post and DELETE.
Firstly, share you the request body samples which for approval and check added.
1) Add approval to this environment:
{
"type": {
"id": "8C6F20A7-A545-4486-9777-F762FAFE0D4D", // The fixed value for Approval
"name": "Approval"
},
"settings": {
"approvers": [
{
"id": "f3c88b9a-b49f-4126-a4fe-3c99ecbf6303" // User Id
}
],
"executionOrder": 1,
"instructions": "",
"blockedApprovers": [],
"minRequiredApprovers": 0,
"requesterCannotBeApprover": false // The pipeline requester allow to approve it.
},
"resource": {
"type": "environment",
"id": "1", // Environment id
"name": "Deployment" //Environment name
},
"timeout": 43200 // Set the available time(30d) of this approval pending. The measure unit is seconds.
}
2) Add task check, Azure function, Invoke rest api task and etc:
{
"type": {
"id": "fe1de3ee-a436-41b4-bb20-f6eb4cb879a7", // Fixed value if you want to add task check
"name": "Task Check" //Fixed value
},
"settings": {
"definitionRef": {
"id": "537fdb7a-a601-4537-aa70-92645a2b5ce4", //task Id
"name": "AzureFunction", //task name
"version": "1.0.10" //task version
},
"displayName": "Invoke Azure Function", //task display name configured
"inputs": {
"method": "POST",
"waitForCompletion": "false",
"function": "csdgsdgsa",
"key": "436467543756" // These are all task inputs
},
"retryInterval": 5, // The re-try time specified.
"linkedVariableGroup": "AzKeyGroup"// The variable group name this task linked with
},
"resource": {
"type": "environment",
"id": "2",
"name": "Development"
},
"timeout": 43200
}
In this request body, you can find the corresponding task id from our public source code. Just check the task.json file of corresponding task.
3) Add template check:
{
"type": {
"id": "4020E66E-B0F3-47E1-BC88-48F3CC59B5F3", // Fixed value for template check added.
"name": "ExtendsCheck" //Fixed value
},
"settings": {
"extendsChecks": [
{
"repositoryType": "git", // github for Github source, bitbucket for Bitbucket source
"repositoryName": "MonnoPro",
"repositoryRef": "refs/heads/master",
"templatePath": "tem.yml"
}
]
},
"resource": {
"type": "environment",
"id": "6",
"name": "development"
}
}
In this body, if the template source is coming from github or bitbucket, the value of repositoryName should like {org name}/{repos name}.
Hope these are helps.
This is an older question but we had a similar need. There does not appear to be a direct API To query this, but this GitHub Project pointed us in the right direction:
# GET ENVIRONMENT CHECKS (stored under .fps.dataProviders.data['ms.vss-pipelinechecks.checks-data-provider'].checkConfigurationDataList)
GET https://dev.azure.com/{{organization}}/{{project}}/_environments/{{environment_id}}/checks?__rt=fps&__ver=2
As mentioned above under .fps.dataProviders.data['ms.vss-pipelinechecks.checks-data-provider'].checkConfigurationDataList the list of who is authorized is provided.
The officially documented APIs can tell you that there are checks in place; for example:
GET https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations?resourceType=environment&resourceId={id}
Can tell you that you have checks enabled (including an Approval check) but this isn't super useful as it does not give a list of who can Approve.
Note that you can get the list of environments (to get their resource ID) using this documented API:
GET https://dev.azure.com/{organization}/{project}/_apis/distributedtask/environments?api-version=7.1-preview.1
This is not supported at the moment. You can upvote feature request to show your interest here.

How to use roomHint and structureHint with smarthome actions on Google

We are currently setting un a Smarthome action, and we would like to provide roomHint on the first sync (not on request sync) as it's really tedious to set up rooms on the first sync, but it does not work.
We tried to name rooms in english and also in italian, (as it's not really clear from the documentation if there is a list on room names that we can use?) but no way.
So can you please give us a hint how to use the roomHint field?
Also in the API doc we've found structureHint, does it work? The documentation for SYNC intent does not mention this field.
Here is our SYNC intent with one device and room, we took office from the example JSON:
{
"requestId": "3582198904737125163",
"payload": {
"agentUserId": "xyz#qwertyz.com",
"devices": [
{
"id": "deviceID",
"type": "action.devices.types.LIGHT",
"traits": [
"action.devices.traits.OnOff"
],
"name": {
"name": "Lampadina",
"defaultNames": [
"Lampadina_XYZ"
],
"nicknames": [
"Lampadina"
]
},
"willReportState": false,
"customData": {
"modelType": "DEVICE"
},
"roomHint": "office"
}
]
}
}
Thanks
Unfortunately, I believe the structureHint is only in the HomeGraph API sync response.
It cannot be used in the Sync intent.
If someone can tell me I'm wrong and how to use it, you'd be a hero.

Unable to add Firebase Dynamic Links to a project using a custom domain

I've created Firebase Dynamic Links in other projects before using the page.link URL prefix (the only option at the time). However that no longer appears to be an option when enabling Dynamic Links for a new project today. It looks like the docs for custom domains were updated today. Unfortunately, while they provide some helpful examples, they don't explain how to resolve my issue in a way that I can understand.
So this message seems to indicate that I need to "Put links under a subpath". It seems to me that adding the /link path prefix here should accomplish that? But after making that change, I get the same error message.
It looks like you already have content served on this Hosting site. Put links under a subpath to avoid conflicts with existing content.
I order to try to work around this, I went to my project and added the suggested Hosting configuration and deployed it.
firebase.json:
{
"hosting": {
"public": "dist",
"ignore": [
"**/.*"
],
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/link/**",
"dynamicLinks": true
},
{
"source": "**",
"destination": "/index.html"
}
]
}
}
Even after waiting an hour, I keep getting the same error and I don't understand what to do.
Note that I have the rewrite to /index.html because I have an Angular Single Page Application hosted at www.devintent.com.
No matter what I do, I keep getting this error and the Continue button stays disabled. I tried using my naked domain devintent.com instead of www.devintent.com, but that didn't help. I tried using links.devintent.com, but got the same error.
If I manually remove disabled from the Continue button, then I get this error message:
This links to the docs for manually configuring hosting for dynamic links which has some steps that I've already completed. Clicking the Check Again button just takes me back to the same error in the first image above.
Workaround to not use Custom Domains
I'm happy at this time to use a page.link link, I just need to create a Dynamic Link and get unblocked on this task, but I can't figure out any way in the console to allow me to do that either.
Update on this: I figured out that I needed to add the subdomain to the page.link URL. The tooltip says "or a free Google-provided domain (for example, yourapp.page.link)" at the end. This is a little less prominent that I would have liked (as I didn't find it for quite a long time). Using devintent.page.link works for me as a workaround for now.
However, I'm not sure why the Custom Domain configuration didn't work and why it would be the default if there are such complications with projects with existing Hosting configurations and custom domains.
I had the same issue and got the same error. The problem was that I was redirecting all the routes to index.html. The solution was to restrict the routes to index.html by exclusion.
"rewrites": [
{
"source": "/link/**",
"dynamicLinks": true
},
{
"source": "!/link/**",
"destination": "/index.html"
}
]
After deploying the new configuration to Firebase Hosting, I was allowed to use mydomain.example/link as desired.
I had a similar problem with the root (apex) domain. Basically, if the prefix (the apex domain in my case) is a URL that gives 200 status response, it won't be accepted. In my case the there was an index.html file inside the public folder. I renamed it to something else and it worked.
Here's my firebase.json:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"appAssociation": "AUTO",
"rewrites": [ { "source": "/**", "dynamicLinks": true } ]
}
}
Everything you are doing looks correct with regards to getting your custom domain working. I am wondering if you are using the latest version of firebase-tools (CLI). Custom Domain support for dynamic links was added in version 6.5.0.
Good news is that page.link support still exists but is not as obvious in the new UI flow. The way to get a page.link domain is to start typing your desired subdomain and a suggestion should pop up in the UI. I have included a screenshot to show how this would work.
Adding page link domain image
Hope this helps,
Jeff
For us the issue was that we we're using the default Firebase Hosting site for serving our web-app at all routes ("/**"). Serving our web-app from a different domain that dynamic links is the way it should be for us, since links should not interfere with the web-app.
To serve links from a different domain than our web-app, I created a new site just for links and attached our custom domain to that site. Now we have two Firebase Hosting sites. The first default one for our web-app and the second one for Firebase Dynamic Links.
After this setting up Dynamic Links with a custom domain attached to the second Firebase Hosting site worked flawlessly.
See the screenshot for more details:
EDIT1: the web-app's firebase.json as requested by #cocacrave:
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"function": "nuxtApp"
}
]
}
}
If you are getting this error with subdomain, this solution worked for me:
{
"hosting": [
{
"target": "app",
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/**",
"destination": "/index.html"
}
]
},
{
"target": "links",
"public": "build",
"ignore": [
"**"
],
"appAssociation": "AUTO",
"redirects": [
{
"source": "/",
"destination": "{{your domain}}",
"type": 302
}
],
"rewrites": [
{
"source": "/**",
"dynamicLinks": true
}
]
},
{
"target": "invite",
"public": "build",
"ignore": [
"**"
],
"redirects": [
{
"source": "/",
"destination": "{{your domain}}",
"type": 302
}
],
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/**",
"dynamicLinks": true
}
]
}
]
}
"appAssociation": "AUTO",
"rewrites": [
{
"source": "/page/**",
"destination": "/index.html"
},
{
"source": "/link/**",
"dynamicLinks": true
}
]
It works! I guess the error caused by the original config of "source":"**". May be the range is too large? Though doc say "/__/*" have high priority. (https://firebase.google.com/docs/hosting/full-config?authuser=0#hosting_priority_order)

Old notifications pushed immediately when subscription is created

I'm using Fiware Orion Context Broker version 0.20.
I notice that when I create a context subscription, my provided endpoint immediately gets notified about changes to the corresponding context elements that happened before I created the subscription.
To clarify: (note: I used these steps with a clean database)
I started the accumulator from the test package /usr/share/contextBroker/tests/accumulator-server.py 1028 /accumulate on
Created a context element using http://localhost:1026/v1/updateContext
{
"contextElements": [
{
"type": "Room",
"isPattern": "false",
"id": "Room1",
"attributes": [
{
"name": "temperature",
"value": "20"
}
]
}
],
"updateAction": "APPEND"
}
Then I created the subscription using http://localhost:1026/v1/subscribeContext
{
"entities": [
{
"type": "Room",
"isPattern": "true",
"id": ".*"
}
],
"attributes": [
"temperature"
],
"reference": "http://localhost:1028/accumulate",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"temperature"
]
}
],
"throttling": "PT5S"
}
I immediately receive the following content in the accumulator
POST http://localhost:1028/accumulate
Content-Length: 472
User-Agent: orion/0.20.0 libcurl/7.19.7
Host: localhost:1028
Accept: application/xml, application/json
Content-Type: application/json
{
"subscriptionId" : "55521671985dc3976b879780",
"originator" : "localhost",
"contextResponses" : [
{
"contextElement" : {
"type" : "Room",
"isPattern" : "false",
"id" : "Room1",
"attributes" : [
{
"name" : "temperature",
"type" : "",
"value" : "20"
}
]
},
"statusCode" : {
"code" : "200",
"reasonPhrase" : "OK"
}
}
]
}
Furthermore, if I create multiple contextElements before adding the subscription, they are all part to the contextResponses in the notification.
For my use case, this behavior is undesirable. The subscriptions are very dynamic (they come and go often throughout the lifecycle of the application) and I do not want the entire history every time I create a subscription. I only want to be notified about changes starting from the moment T created the subscription. (Not a history)
Did I overlook something in the documentation and can I resolve this by changing the contents of the subscription request? If not, is this generally accepted behavior for the context broker or just a plain bug?
It is the expected behaviour, as described in the manual:
You may wonder why accumulator-server.py is getting this message if you don't actually do any update. This is because the Orion Context Broker considers the transition from "non existing subscription" to "subscribed" as a change.
We understand that for some uses cases this is not convenient. However, behaving in the opossite way ruins another uses cases which need to know the "inicial state" before starting getting notifications corresponding to actual changes. The best solution to make everybody happy is to make this configurable, so each client can chose what it prefers. This feature is currently in our roadmap (see this issue in github.com).
While this gets implemented in Orion, in your case maybe a possible workaround is just ignore the first received nofitication belonging to a subscription (you can identify the subscription to which one notification belongs by the subscriptionId field in the notification payload). All the following notifications beloning to that subscription will correspond to actual changes.
EDIT: the posibility of avoiding initial notification has been finally implemented at Orion. Details are at this section of the documentation. It is now in the master branch (so if you use fiware/orion:latest docker you will get it) and will be include in next Orion version (2.2.0).

Subscribing to an entity without specifying attributes

I'm trying to subscribe to an entity to get notifications using ONCHANGE.
The thing is that I'd like to get notified when new attributes get added or removed from the entity, otherwise said, I want a notification whenever anything changes on that entity.
Is that possible? I tried setting an empty condValues list in the query like this:
{
"entities": [
{
"type": "case",
"isPattern": "false",
"id": "Case1"
}
],
"reference": "http://localhost:1028/accumulate",
"duration": "P1M",
"notifyConditions": [
{
"type": "ONCHANGE",
"condValues": [
"Test Node 1"
]
}
],
"throttling": "PT5S"
}
But it didn't work.
PS: Note that I omitted the attributes Array to receive all the attributes on notification, this does work.
Current Orion version (0.19.0) doesn't implement such feature. However, it is planed to be done in the future (see this issue at Orion github repository).
EDIT: since Orion 0.27.0 you can subscribe to changes in any attribute. In order to do so, do the subscription omitting the condValues field (or use an empty array [] as value).