My First Post      My Facebook Profile      My MeOnShow Profile      W3LC Facebook Page      Learners Consortium Group      Job Portal      Shopping @Yeyhi.com

Pages










Showing posts with label map. Show all posts
Showing posts with label map. Show all posts

Thursday, January 30, 2020

Mapping template, Velocity Language & JsonPath: Guide to Api Gateway mapping templates mechanism

Amazon’s API Gateway provides the facilities to map an incoming request’s payload to match the required format of an integration backend. It uses the concept of “models” and “mapping templates” to specify the mapping between the client payload and the server payload.

The API Gateway mapping templates are used to transform an incoming payload into a different format. API Gateway allows you to define input mapping templates, for mapping the incoming request from a client to a server format, and output mapping templates, for mapping the outgoing response from the server to a client format.

Let us all remember that the mappings are defined using the Velocity Template Language combined with JSONPath expressions.

Velocity is a Java-based templating engine that uses a template language to reference objects in Java code. Velocity can be used to generate web XML, HTML or SQL from templates, for example. Here, we will use it to define the mapping between an input and output model.
A Velocity Template Language (VTL) template is composed of statements which begin with the # character and a followed by a directive. Also, it has references, which begin with the $ character. More generally, references begin with $ and are used to get or set something. Directives begin with # and are used to do something.
We can use the statement above to define an HTML template that sets a reference to a value, and retrieves that reference.

  
  #set( $foo = "Velocity" )
  Hello $foo World!
  
For more on VTL, consult the user guide.

In API Gateway mapping templates, the input to your Velocity template is defined by the reference variable $input. To access particular portions of the input JSON document within the template, use JSONPath.
JSONPath provides an XPath-like method of referring to a JSON structure. IN JSONPath, the abstract name $ refers to the root-level object. From this root-level object, you can use dot-notation to select more restrictive portions of the document. 
For example, to reference the playerId of the player model, you would use the following JSONPath expression.
$.playerId
or, you can use a bracket-notation to perform the same selection.
#['playerId']
More complex selections can be done using * for a wildcard, @ to refer to the current node in the document, array indexing, or recursive descent.

Now, we can put together a mapping template for our Player model. This template will just copy the input to the output with new names for field properties. In particular, it will convert an input document of
{
    "id": "AJamal",
    "alias": "Aha Jamal",
    "displayName": "Anwar Jamal Faiz",
    "profilePhotoUrl": "https://api.example.com/player/AJamal/avatar.png"
}
to an output document of
{
    "id": "AJamal",    "alias": "Aha Jamal",    "name": "Anwar Jamal Faiz",    "photo": "https://api.example.com/player/AJamal/avatar.png"}
The mapping to perform the above transformation is specified below, with some inline VTL comments added.
## Set the variable inputRoot to the root JSON document
#set($inputRoot = $input.path('$')) {

    ## Assign output properties to input properties
    "id": "$inputRoot.playerId",
    "alias": "$inputRoot.alias",
    "name": "$inputRoot.displayName",
    "photo": "$inputRoot.profilePhotoUrl"
}
Enjoy!!

Tuesday, February 28, 2017

CD with mapped mounted drive on network : CHDIR command


It has happened with me that I was able to succesfully mount a network drive and can freely access it using Windows file-system Explorer. But my script was not able to access it. Digging a step further, i noticed that I could not even CD to that drive on command prompt. Hence i finally wrote this blog post for anyone running into the similar issue.

Question : How do I change to a mapped network drive at the command line?

Issue:
Say, you have a networked drive mapped to "U:\"
Now you want to go to that drive from a command line.
However, when you try you get an error suggesting
C:>u: The system cannot find the drive specified.


Solution:
There are two aspects to the solution:
1. The Syntax to use CD command on Windows may be the cause. Remember that for changing directories you should use cd /d U: rather than just U:
2. You should first start using the map drive on command prompt. Command used to do that is as follows:
net use u:

See attached screenshot showing the error as well as what happened after solution.




C:\Users\mfaiz\Downloads>net use p:
Local name        p:
Remote name       \\sxa.xxx.xxx.com\ap-xxx
Resource type     Disk
The command completed successfully.

Friday, December 16, 2011

GeoBing by Anwar Faiz: First Facebook App using Bing Maps

I have developed a new Facebook Application and wanted to post something about that.


Name of the Facebook App: GeoBing

Description: Use the GeoBing App to share your location on Facebook using Microsoft's Latest Bing Maps. Your Profile would get updated with your current location and map.

Importance: GeoBing Facebook Application is the world's first innovative way to share your Geographical Location over Facebook using Bing Maps. You can even do it from your Laptop and Desktop Browsers.!!

GeoBing FaceBook Link: http://apps.facebook.com/geobing/?ref=ts

Steps to use:
Step 1: Click this button Show map. [You need to click this]

Step 2: When prompted, allow your location to be shared to see Geolocation in action

Step 3: When you see your Location information on the Map below, Click 'Post to Facebook' button on the bottom.

Effect: Your geographical location would be posted over your Facebook profile page.

Help promoting this App. This was designed in curiosity to use Bing Maps. And I am happy and glad to let you all know, GeoBing is the first Facebbok Application that uses Microsoft Bing Maps to post your Geographical location. This works from your desktop, laptops, handheld devises, Samsung Galaxy S2, Iphone, Ipads etc.

Love u all.
Keep clicking advertisements. Keep reading more original contents.
-Mohd Anwar Jamal Faiz