# Entity Reference

# View

# data

The default view type is a data view, which performs the following steps:

  1. Transform the incoming HTTP request object using the specified request glyphs
  2. Execute the resulting transformed object as a DataServiceRequest using the root profile specified in config
  3. Transform the raw DataServiceResponse using the specified response glyphs
  4. Respond using the transform output as the final response body and the configured media type (the default is application/json)

The following is an example config snippet for a single data view:

rosetta:
  view:
    views:
      - name: my-example-view
        paths:
          - /my/example/path
        methods:
          - GET
        profile: example-profile
        transforms:
          request:
            policy: list
            names:
              - example-view-request-transform
          response:
            policy: list
            names:
              - example-view-response-transform

Note this example view depends on the existence of a profile called example-profile and two glyphs with names example-view-request-transform and example-view-response-transform.

# Properties

See DataView.

# data-multi

A data-multi view is similar to a data view but can execute multiple data service requests within a single HTTP request. This view performs the following steps:

  1. Transform the incoming HttpDataRequest into a map whose keys are arbitrary and each value is a DataServiceRequest.
  2. Execute each DataServiceRequest in turn and construct a new map from the resulting DataServiceResponse objects, associating each with the corresponding key from step 1).
  3. Transform the map of DataServiceResponse objects into the final response body.
  4. Respond using the final response body and configured media type.

# Properties

See DataView.

# transform-only

A transform-only view is perhaps the simplest type of view, as it simply transforms the incoming HTTP request using the specified glyphs and responds with the output.

The following is a simple example transform-only view, along with config for the double-my-arg glyph used by the view:

rosetta:
  view:
    views:
      - name: example-transform-only
        type: transform-only
        paths:
          - /example/transform/only
        methods:
          - GET
        glyphs:
          policy: list
          names:
            - double-my-arg

  transform:
    glyphs:
      - name: double-my-arg
        type: proteus
        properties:
          spec: /rosetta/config/proteus/double-my-arg.json

File: /rosetta/config/proteus/double-my-arg.json

{
  "result": {
    "#type": "maths",
    "expression": "2*{$.query.arg}"
  }
}

With this config deployed on a Rosetta server running on port 4923, the request GET http://localhost:4923/example/transform/only?arg=7 would respond with:

{
  "result": 14
}

In the above, we can see that the arg query string parameter has been dynamically marshalled into the input of a maths Proteus component via the $.query.arg JSONPath expression, which doubles the value of this parameter and places the result under the result top-level key of the JSON output.

# Properties

As BaseView but with the following additional properties.

Property Type Default Description
media_type String application/json The media (or MIME) type of the response body for this view.
glyphs Selector The glyphs to apply to the incoming HttpDataRequest to produce the final response body.

# Profile

Unlike other kinds of entity, Profiles do not have types and have a fixed schema, which is described in the Profile section of the data structures page.

# Provider

No providers are defined in core Rosetta (see plugins).

# Glyph

# to-generic-search

The to-generic-search Glyph transforms an HttpDataRequest into a DataServiceRequest whose request field is populated by a GenericSearchRequest, either using query string parameters or the request body.

If the query string parameters are used, then each parameter string value will be parsed into their respective fields of GenericSearchRequest according to the following rules:

  • The parameter q is parsed as the sole item within the queries field.
  • The parameters ids and aggs are converted into their respective array fields by splitting on the , character.
  • The parameters field and autocomplete are interpreted as maps where each entry is delimited by the ; character and the key and value are separated by the : character.
  • The parameter filter takes the following form:
    filter_1:((value_1),(value_2),...,(value_n));filter_2:(value_i,value_ii,...,value_m)
    where each filter_x is the name of a searchable field and each value_y is a value for that field.
  • The parameter sort takes the following form:
    sort_1:direction_1,sort_2:direction_2,...,sort_n:direction_n
    where each sort_x is the name of a searchable field and each direction_x can be either asc or desc for ascending and descending order, respectively.
  • The parameters from and size are interpreted literally.

If the request body is used instead, then the body is literally interpreted as a GenericSearchRequest.

# Properties

Property Type Default Description
types Enum[] { query, body } [ body, query ] The part(s) of the HTTP request that this Glyph will attempt to use as the input for the transformation. Each type is attempted in order, falling back to the next type if the specific source is empty.

# Example

name: my-glyph
type: to-generic-search
properties:
  types:
    - query
    - body

# to-simple-data-response

The to-simple-data-response Glyph converts a DataServiceResponse to a SimpleDataResponse by selecting the sole result set available in the input and rendering it in isolation.

If multiple result sets are found in the input (e.g. if multiple providers are configured in the profile), then an exception will be thrown.

# Properties

This Glyph has no properties.

# Example

name: my-glyph
type: to-simple-data-response