Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Originally created by Lan B Dang, last modified on Jul 25, 2017

Page Navigation:

Table of Contents


(blue star) Confidence Level TBD  This article has not been reviewed for accuracy, timeliness, or completeness. Check that this information is valid before acting on it.

Intro

The X-Fields parameter in our Mozart Swagger API is provided by Flask-RESTPlus.  It is used by Flask-RESTPlus to support partial object fetching.  The syntax is to provide a comma-separated list of field names.  The use of curly braces is optional, but you will want to use it if you are trying to access nested data.

A great use case for X-Fields is when you are running a query that can pull back a lot of metadata, but you are only interested in one or two fields.  For example, in the Mozart job operations API, the /job/info will provide complete information on a job, given a payload id.

It will take some experimentation to figure out what the X-fields mask should be.  If you have a tool that will break up the nesting of the full JSON results from /job/info, you will have an advantage in constructing the mask.

JSON Example

Here is an example of the normal output for a given job id:

Expand
titleTODO: include the output JSON file
Code Block
languagejson
{
  "message": "",
  "result": {
    "status": "job-completed",
    ...
  }
}

Here is the output, if you use this X-fields mask, which drills into the job_info facts in order to determine ec2_instance_type:

Code Block
{result{job{job_info{facts{ec2_instance_type}}}}}

This is the much shorter result that is returned, after filtering.

Code Block
languagejson
{
  "result": {
    "job": {
      "job_info": {
        "facts": {
          "ec2_instance_type": "r4.8xlarge"
        }
      }
    }
  }
}


(lightbulb) Have Questions? Ask a HySDS Developer:

Anyone can join our public Slack channelto learn more about HySDS. JPL employees can join #HySDS-Community

(blue star)

JPLers can also ask HySDS questions atStack Overflow Enterprise

(blue star)

Live Search
placeholderSearch HySDS Wiki