Looking at the documentation here it appears there is no way of getting the requestTime from the context variable.
Is there any other way, apart from using a lambda resolver, to get that value?
I know it is possible when using API Gateway, so surely there is a way. Am I looking at the wrong thing?
Thanks
Julien
(I work on the AWS AppSync team)
You're right, we do not yet expose the request time inside the mapping template.
May I ask what your use case is?
This is valuable feedback, I'm going to make sure this gets seen by the team. I will update this thread as we have more information.
UPDATE: We now support extracting the current timestamp via mapping template helper methods.
Here are a few functions that can help you achieve what you need:
$util.time.nowISO8601() : 2018-02-06T19:01:35.749Z
$util.time.nowEpochSeconds() : 1517943695
$util.time.nowEpochMilliSeconds() : 1517943695750
$util.time.nowFormatted("yyyy-MM-dd HH:mm:ssZ") : 2018-02-06 19:01:35+0000
$util.time.nowFormatted("yyyy-MM-dd HH:mm:ssZ", "+08:00") : 2018-02-07 03:01:35+0800
$util.time.nowFormatted("yyyy-MM-dd HH:mm:ssZ", "Australia/Perth") : 2018-02-07 03:01:35+0800
The complete reference is available on the Resolver Mapping Template Utility Reference page.
Related
Hey I m using MessageRoutingCallback to route to a function in spring cloud functions. It needs FunctionRoutingResult for routing. I also wanted to edit the message. The spring cloud docs says.
"Additionally, the FunctionRoutingResult provides another constructor allowing you to provide an instance of Message as second argument to be used down stream".
But the problem is the constructor with Message type in FunctionRoutingResult is internal and cannot be accessed outside.
Am I doing something wrong here. Any insight would be helpful
Couple of things.
As the documentation explains it is made to assist with routing decisions. For example if routing decision should be made based on payload which may need to be temporarily converted.
The reality is that it is a very bad practice to let framework make such decisions based on the payload, since payload is a privileged information. Similar to the letter in the envelope where mailman does not read the actual letter to make proper routing decisions. .. those all come from the envelope itself. So I will actually update the documentation to remove that paragraph.
And it is definitely not there to modify the message. That would be improper use of MessageRoutingCallback. To modify message you can use function composition. For example MessageRoutingCallback you check some header in the incoming message, determined that the function name should be foo but then actually output modifier|foo as function definition.
Is there a way to call Template Query using NEST? Is there any examples?
The search template endpoint isn't mapped in NEST yet, and poses a bit of a challenge since it's very different to how queries are normally constructed. We're actually working on this now (in this branch) and are hoping to get this functionality in the upcoming 1.1 release. Here's a link to the original issue for tracking purposes.
EDIT: Forgot to mention, the endpoint is available on the low-level Elasticsearch.Net client, which you can access via ElasticClient:
var client = new ElasticClient(...);
client.Raw.SearchTemplate(...);
The search template endpoint has been mapped in NEST 2.x.
There is a general example about templating here:
https://www.elastic.co/guide/en/elasticsearch/client/net-api/2.x/template-query-usage.html
Here is some information about how inline templates can be used in a phrase suggestion with the collate option:
https://www.elastic.co/guide/en/elasticsearch/client/net-api/2.x/suggest-usage.html
Here is an issue on GitHub I posted with some information on how to save templates to Elastic:
https://github.com/elastic/elasticsearch-net/issues/2176
Here's a general example of how to use NEST:
var templateRequest= new PutSearchTemplateDescriptor(new Id("my_template"));
templateRequest.Template("{\"multi_match\":{\"query\":{\"query\":\"{{suggestion}}\",\"fields\":[\"field1\",\"field2\"]}}}");
var response = ElasticClient.PutSearchTemplate(templateRequest);
When using the template in a suggest collate:
.Collate(c => c
.Query(q => q
.Indexed("my_template")
)
.Prune()
)
Another question on similiar lines, Is PutSearchTemplateDescriptor the write method to call a pre-regsitered template?
I have registered the template to the .scripts but unable to find the right method to call the template from NEST client
I am currently in the process of writing a custom DataProvider. Using the Intergrate External Data documentation.
I've managed to show the external data in the Sitecore back end. However whenever I try to view the data in the items I created, I am getting an error
Null ids are not allowed. <br> Parameter name: displayName
There seems to be precious little on the subject on how to create a custom DataProvider on the Sitecore Developer Network.
The example on their website seems to only show how to import a SINGLE item into a static database. However I am simply trying to merge some items into the hierarchy and I can't find any useful documentation.
It seems that one of your methods that should return an ID doesn't. It might be GetChildIds and/or GetParentId.
Nick Wesselman wrote a good article about it gathering all the information including an example on the Marketplace. I think that is your best start. You can read it here.
Turns out I needed to include at the very least, the Fields->Section->Template in the GetParent method. To be on the safe side I included the Fields/Sections/Templates into my implementations of
GetChildIDs
GetItemDefinition
GetParentID
It wasn't obvious that this was the case, since I had in fact implemented the GetTemplates method correctly, and I had expected that should be enough.
I am trying to find if there is any best practices involved in developing/implementing a GET operation.
I was going through the web resource documentation of jersey.
URL : http://jersey.java.net/nonav/apidocs/1.4/jersey/com/sun/jersey/api/client/WebResource.html
If we look at the methods that are available, the 'get' doesn't accept entity.
Is it recommended to implement get operation which doesnt accept entity but only get request parameters from Query Parameters?
Thanks,
GK
Yes. Think of the URI as the unique identifier to the object/resource you are GETing. I typically use query params for a GET if required. More normally I just have a GET something like this: GET: https:/myservice.com/myobject/id. This path is usually returned from a PUT or POST operation on MyObject. If I want to look up one or more I then use query params for the criteria.
There are a number of best practices out there. One that seems to bring together most of the common ones in a readable format is provided by Apigee. You can obtain it from http://info.apigee.com/Portals/62317/docs/web%20api.pdf
I'd like to use my resource in a view to bootstrap app's data.
I saw a way of doing it in the cookbook: http://django-tastypie.readthedocs.org/en/latest/cookbook.html#using-your-resource-in-regular-views
However, I was wondering whether there is a more straightforward way to do it?
Moreover, unlike the example, I want to return several objects so I used obj_get_list()[0:20] but the bundle is looking for a "pk" so I cannot use it like that. It does not work. How would you do it?
Thanks.
How about using get_object_list() or just _meta.queryset() ? But if you're not performing a GET request from within your view (which would really be using you API) then I wonder if it's not better to just do Model.objects.all().