We had Fiware Orion running on local instance - we had issue with notification received.
We need a way to append an identifier with callback url like http://localhost:1028/orion_callback.php?car_id=car_1 or get some data along with call back as Post/Get data.
How do we identify notification recieved for this attribute change ?
You can identify the subscription to which a notification belongs (thus, related with an entity/attribute change) by the subscriptionId field in the notification payload body.
If the question is about adding query parameters to notification URL (i.e. car_id=car1 in your example) you can use custom notifications in NGSIv2.
Based in the example in the question and assuming that car1 refers to entity id you could use something like this:
"httpCustom": {
"url": " http://localhost:1028/orion_callback.php",
"qs": {
"car_id": "${id}"
}
}
Have a look to "Custom Notifications" section in the NGSIv2 specification for details.
Related
I'm designing a REST api for running jobs on virtual machines in different domains (Active Directory domains, the virtual machines with the same name can exist in different domains).
/domains
/domains/{dname}
/domains/{dname}/vms
/domains/{dname}/vms/{cname}
And for jobs, which will be stored in a database
/jobs
/jobs/{id}
Now I need to add a new API for the following user stories.
As a user, I want to run a job (just job definition, not the stored job) on an existing VM.
As a user, I want to run a job (just job definition, not the stored job) on VM named x, which may or may not exist. The system should create the VM if x doesn't exist.
How should the api be designed?
Approach 1:
PUT /domains/{dname}
{ "state": "running_job", "vm": "vm_name", "job_definition": { .... } }
Approach 2:
PUT /domains/{dname}/vms/{vm_name}
{ "state": "running_job", "job_definition": { .... } }
Approach 3:
PUT /jobs
{ "state": "running", "domain": "name", "vm": "vm_name", "job_definition": { .... } }
Approach 4: create a new resource, saying scheduler,
PUT /scheduler
{ "domain": "name", "vm": "vm_name", "job_definition": { .... } }
(what if I need to update some attributes of scheduler in the future?)
In general, hwo to design the REST API url which needs multiple resources?
How should the api be designed?
How would you design this on the web?
There would be an HTML form, right? With a bunch of input controls to collect information from the operator about what job to use, and which VM to target, and so on. Operator would fill in the details, submit the form. The browser would then use the form to create the appropriate HTTP request to send to the server (the request-target being computed from the form meta data).
Since the server gets to decide what the request-target should be (benefits of using hypertext), it can choose any resource identifier it wants. In HTTP, a successful unsafe request happens to invalidate previously cached responses with the same request target, so one possible strategy is to consider which is the most important resource changed by successfully handling the request, and use that resource as the target.
In this specific case, we might have a resource that represents the job queue (ex /jobs), and what we are doing here is submitting a new entry in the queue, so we might expect
POST /jobs HTTP/1.1
....
If the server, in its handling of the request, also creating new resources for the specific job, then those would be indicated in the response
HTTP/1.1 201 Created
Location: /jobs/931a8a02-1a87-485a-ba5b-dd6ee716c0ef
....
Could you instead just use PUT?
PUT /jobs/931a8a02-1a87-485a-ba5b-dd6ee716c0ef HTTP/1.1
???
Yes, if (a) the client knows what spelling to use for the request-target and (b) is the client knows what the representation of the resource should look like.
Which unsafe HTTP method you use in the messages that trigger you business activities doesn't actually matter very much. You need to use the methods correctly (so that general purpose HTTP connectors don't get misled).
In particular, the important thing to remember about PUT is that the request body should be a complete representation of the resource - in other words, the request body for a PUT should match the response body of a GET. Think "save file"; we've made local edits to our copy of a resource, and we send back a copy of the entire document.
I have a Google cloud function that is being triggered by a Pubsub push subscription.
I wish to know the current delivery attempt of the given message.
In pull subscription it works by setting dead letter topic, however I am not able to get the delivery attempt in a push subscription message attributes. Tried to configure a dead letter topic and delivery_attempt attribute is not in message attributes.
Is there a way to get the delivery attempt parameter in a push subscription?
For push subscriptions, use deliveryAttempt, not delivery_attempt. The documentation calls out this here:
When Pub/Sub forwards undeliverable messages from a push subscription, every message you receive from the subscription includes the deliveryAttempt field.
I am not sure it is possible to get that data explicitly... but I can suggest an idea of a workaround for consideration.
Every time a cloud function is invoked, you can (in your code) create/update a firestore document with some unique id (either a message event id, or some unique business related identifier). That document may have attributes, one of which - is the time and/or the attempt number.
in java you can use a static method of Subscriber class.
for a PubsubMessage message;
com.google.cloud.pubsub.v1.Subscriber.getDeliveryAttempt(message);
As de documentation sais Returns the delivery attempt count for a received PubsubMessage.
Integer maxAttemps = 5;
private void killMessage(Event<String> event, Exception en,
BasicAcknowledgeablePubsubMessage acknowledgeable) {
Integer attemps = Subscriber.getDeliveryAttempt(acknowledgeable.getPubsubMessage());
if(attemps.intValue() < maxAttemps) {
acknowledgeable.nack();
return;
}
sendToErrorQueue(event, en, acknowledgeable);
}
https://googleapis.dev/java/google-cloud-pubsub/latest/com/google/cloud/pubsub/v1/Subscriber.html
I am working with cas-overlay-template project in version 6.1.4. I have implemented two mfa providers on my CAS, Google Authenticator and CAS Simple. Both are working, I have tested them separately and I have got the results I've expected.
Until now, I have been activating the mfa modifying the cas.properties file adding this properties: cas.authn.mfa.globalProviderId=mfa-gauth when I wanted to use Google, or cas.authn.mfa.globalProviderId=mfa-simple when I used the CAS itself.
Well, in CAS documentation is mentioned that is possible to enable a provider selection menu, if resolved more than one just by adding this propertie: cas.authn.mfa.provider-selection-enabled=true. So, my configuration is the following:
cas.authn.mfa.provider-selection-enabled=true
cas.authn.mfa.globalProviderId=mfa-gauth
cas.authn.mfa.globalProviderId=mfa-simple
But when I try to login with any user (I'm using the default one casuser:Mellon), CAS don't show me a menu in which I can select the following mfa provider, It directly goes to mfa-simple provider.
What am I doing wrong?
Well, in CAS documentation is mentioned that is possible to enable a provider selection menu, if resolved more than one just by adding this properties:
So far so good.
So, my configuration is the following:
That's the problem. You are not resolving/triggering more than just one provider. You start with mfa-gauth and then override it with mfa-simple. In CAS 6.1.x, the globalProviderId only accepts a single identifier. It's not a list or a container of any kind to accept more than one value. This has been addressed in the next coming release.
At the moment, to resolve more than one provider you will need to assign the MFA providers to a registered service definition. Like so:
{
"#class": "org.apereo.cas.services.RegexRegisteredService",
"serviceId": "^(https|imaps)://.*",
"name": "Example",
"id": 1,
"description": "This service definition defines a service.",
"evaluationOrder": 1,
"multifactorPolicy" : {
"#class" : "org.apereo.cas.services.DefaultRegisteredServiceMultifactorPolicy",
"multifactorAuthenticationProviders" : [ "java.util.LinkedHashSet", [ "mfa-duo", "mfa-gauth" ] ]
}
}
This means, provider selection can be enabled on a per-application basis. Alternatively, you can write a small groovy script to return more than one provider back to CAS, allowing the selection menu to display the menu items.
Read this post for full details.
I know that when I create a payment method I can use failOnDuplicatePaymentMethod to block duplicate cards. But when I use the storeInVaultOnSuccess option with Braintree_Transaction::sale, what is the best way to not save the card if it is already saved?
Edit:
Let me clarify my situation to make sure. On my checkout page I am currently using this JavaScript:
braintree.setup(
myToken,
'custom',
{
id: 'my-form-id',
hostedFields: {
...
},
onPaymentMethodReceived: function(obj) {
...
},
onError: function(obj) {
...
}
}
);
The customer fills in their CC number, CVV and expiration date and clicks submit and then that onPaymentMethodReceived callback fires. In that JS callback I make an AJAX call to my back-end and pass the nonce. On the back-end I call Braintree_Transaction::sale in order to charge the customer.
I always need Braintree_Transaction::sale to successfully complete so that the sale goes through. And then in addition so this sale, I want the card to be saved if the customer has checked "save my card" and the card isn't already saved.
On this checkout page, the customer does have the option to select a saved card instead of inputting all their card info again, but they may type all the card info in again(for an already saved card) instead of selecting the saved card.
How would you do it given this setup? Does your below setup still apply? If so how exactly would I integrate the below with my above setup? Or do I need to rearrange my UI/UX for this(I think this is a pretty standard checkout flow)?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact support.
There isn't a way to prevent duplicate payment methods when making a Braintree_Transaction::sale API call. However, you can still achieve your goal with some settings on your client. Here are those steps:
On your server, create a client token and include the customer_ID and the failOnDuplicatePaymentMethod parameters:
```
$clientToken = $gateway->clientToken()->generate([
"customerId" => "aCustomerId",
"options" => [
"failOnDuplicatePaymentMethod" => true
] ]);
```
Use this client token as your authorization when creating the Braintree client instance:
```
var createClient = require('braintree-web/client').create;
createClient({
authorization: CLIENT_AUTHORIZATION
}, function (createErr, clientInstance) {
// ...
});
Per Braintree's docs regarding generating a client Token,
If [the failOnDuplicatePaymentMethod] option is passed and the same payment method has already been
added to the Vault for any customer, the request will fail. This can
only be passed if a $customerId is passed as well. If the check fails,
this option will stop the Drop-in from returning a
$paymentMethodNonce. This option will be ignored for PayPal, Pay with
Venmo, Apple Pay, and Google Pay payment methods.
I'm developing a quickblox application using Adobe AIR, which forces me to use the REST Api instead of the native libraries. I can't get the push notifications to work for offline Messages or the admin panel. Here's the details of what I do:
Admin panel:
uploaded Apple certificates for both Devel and Production push notifications
Setup project ID and server key for GCM
on Application Activate:
Register with APNS. Get device token:
XXXXXXX1fd86e783c1410e9b9e41e9f11339e33f17f59bfcc7d6bf9XXXXXXXXX
Generate udid for device. This is not Apple's device UDID, since it is now deprecated. I generate one myself. I'm saying this just in case this could be the problem
Login to Quickblox as user with device info
POST
{
"auth_key":"XXXXXXXXXX",
"nonce":8072,
"user":{
"password":"XXXXXXX",
"login":"XXXXXX"
},
"application_id":"1563",
"timestamp":1363692198,
"device":{
"platform":"ios",
"udid":"71B18699-E1A3-13B6-F8C3-BDBF01AC1FFC-B4B3475569E9-6B6A-A27E-56D1-B73E0ED4"
},
"signature":"d61293bbd98d2e523952c0f30e44ec514fb7f86a"
}
Login is ok. Create push token. As client_identification_sequence I use the token retrieved from Apple
POST
{
"push_token":{
"environment":"development",
"client_identification_sequence":"XXXXXXX1fd86e783c1410e9b9e41e9f11339e33f17f59bfcc7d6bf9XXXXXXXXX"
},
"device":{
"platform":"ios",
"udid":"71B18699-E1A3-13B6-F8C3-BDBF01AC1FFC-B4B3475569E9-6B6A-A27E-56D1-B73E0ED4"
}
}
Quickblox returns a token 153323 so I assume everything is ok
Now create subscription
POST
{
"notification_channels":"apns"
}
Quickblox returns the following
[
{
"subscription":{
"device":{
"udid":"71B18699-E1A3-13B6-F8C3-BDBF01AC1FFC-B4B3475569E9-6B6A-A27E-56D1-B73E0ED4",
"platform":{
"name":"ios"
}
},
"id":167704,
"notification_channel":{
"name":"apns"
}
}
}
]
UDid matches udid I passed from login. Everything looks good
Now I go to Admin panel and try to send Message. Admin panel says:
Notification has been successfully added to queue
If I go to queue, message shows as 'sent' but I never receive the notification in my device.
Any help would be greatly appreciated
your code looks good,
some comments:
1) you dont need to pass
"device":{
"platform":"ios",
"udid":"71B18699-E1A3-13B6-F8C3-BDBF01AC1FFC-B4B3475569E9-6B6A-A27E-56D1-B73E0ED4"
},
params to session, because you are passing them while creating push token
2) udid - it's just to separate users devices, because user can has more than 1 device. So you can pass any value to 'udid' which uniquely identify user's particular device
3) if you have sent message from admin panel - it means i think everything is OK on client side. So just check your APNS certificates, reupload them.