Project: Gloo (Orchestration & Management / API Gateway)
File: transformation.proto.sk.md

title: "transformation.proto" weight: 5 <!-- Code generated by solo-kit. DO NOT EDIT. --> ```yaml "matchers": []matchers.core.gloo.solo.io.HeaderMatcher "responseCodeDetails": string "responseTransformation": .transformation.options.gloo.solo.io.Transformation ``` | Field | Type | Description | | -- | - | -- | | `matchers` | | Response headers to match on. | | `responseCodeDetails` | `string` | Response code detail to match on. To see the response code details for your usecase, you can use the envoy access log %RESPONSECODEDETAILS% formatter to log it. | | `responseTransformation` | | Transformation to apply on the response. | ```yaml "matcher": .matchers.core.gloo.solo.io.Matcher "clearRouteCache": bool "requestTransformation": .transformation.options.gloo.solo.io.Transformation "responseTransformation": .transformation.options.gloo.solo.io.Transformation ``` | Field | Type | Description | | -- | - | -- | | `matcher` | | Matches on the request properties. | | `clearRouteCache` | `bool` | Should we clear the route cache if a transformation was matched. | | `requestTransformation` | | Transformation to apply on the request. | | `responseTransformation` | | Transformation to apply on the response. | ```yaml "requestTransformation": .transformation.options.gloo.solo.io.Transformation "clearRouteCache": bool "responseTransformation": .transformation.options.gloo.solo.io.Transformation ``` | Field | Type | Description | | -- | - | -- | | `requestTransformation` | | Apply a transformation to requests. | | `clearRouteCache` | `bool` | Clear the route cache if the request transformation was applied. | | `responseTransformation` | | Apply a transformation to responses. | ```yaml "requestTransforms": []transformation.options.gloo.solo.io.RequestMatch "responseTransforms": []transformation.options.gloo.solo.io.ResponseMatch ``` | Field | Type | Description | | -- | - | -- | | `requestTransforms` | | Transformations to apply on the request. The first request that matches will apply. | | `responseTransforms` | | Transformations to apply on the response. This field is only consulted if there is no response transformation in the matched `request_transforms`. i.e. Only one response transformation will be executed. The first response transformation that matches will apply. | ```yaml "early": .transformation.options.gloo.solo.io.RequestResponseTransformations "regular": .transformation.options.gloo.solo.io.RequestResponseTransformations "inheritTransformation": bool "logRequestResponseInfo": .google.protobuf.BoolValue "escapeCharacters": .google.protobuf.BoolValue ``` | Field | Type | Description | | -- | - | -- | | `early` | | Early transformations happen before most other options (Like Auth and Rate Limit). | | `regular` | | Regular transformations happen after Auth and Rate limit decisions has been made. | | `inheritTransformation` | `bool` | Inherit transformation config from parent. This has no affect on VirtualHost level transformations. If a RouteTable or Route wants to inherit transformations from it's parent RouteTable or VirtualHost, this should be set to true, else transformations from parents will not be inherited. Transformations are ordered so the child's transformation gets priority, so in the case where a child and parent's transformation matchers are the same, only the child's transformation will run because only one transformation will run per stage. Defaults to false. | | `logRequestResponseInfo` | | When enabled, log request/response body and headers before and after all transformations defined here are applied.\ This overrides the logrequestresponse_info field in the Transformation message. | | `escapeCharacters` | | Use this field to set Inja behavior when rendering strings which contain characters that would need to be escaped to be valid JSON. Note that this sets the behavior for all staged transformations configured here. This setting can be overridden per-transformation using the field `escape_characters` on the TransformationTemplate. | User-facing API for transformation. ```yaml "transformationTemplate": .transformation.options.gloo.solo.io.TransformationTemplate "headerBodyTransform": .transformation.options.gloo.solo.io.HeaderBodyTransform "xsltTransformation": .envoy.config.transformer.xslt.v2.XsltTransformation "logRequestResponseInfo": bool ``` | Field | Type | Description | | -- | - | -- | | `transformationTemplate` | | Apply transformation templates. Only one of `transformationTemplate`, `headerBodyTransform`, or `xsltTransformation` can be

| | `headerBodyTransform` | | This type of transformation will make all the headers available in the response body. The resulting JSON body will consist of two attributes: 'headers', containing the headers, and 'body', containing the original body. Only one of `headerBodyTransform`, `transformationTemplate`, or `xsltTransformation` can be set. | | `xsltTransformation` | | (Enterprise Only): Xslt Transformation. Only one of `xsltTransformation`, `transformationTemplate`, or `headerBodyTransform` can be set. | | `logRequestResponseInfo` | `bool` | When enabled, log request/response body and headers before and after this transformation is applied. | Extractions can be used to extract information from the request/response. The extracted information can then be referenced in template fields. ```yaml "header": string "body": .google.protobuf.Empty "regex": string "subgroup": int "replacementText": .google.protobuf.StringValue "mode": .transformation.options.gloo.solo.io.Extraction.Mode ``` | Field | Type | Description | | -- | - | -- | | `header` | `string` | Extract information from headers. Only one of `header` or `body` can be set. | | `body` | | Extract information from the request/response body. Only one of `body` or `header` can be set. | | `regex` | `string` | The regex field specifies the regular expression used for matching against the source content. - In EXTRACT mode, the entire source must match the regex. `subgroup` selects the n-th capturing group, which determines the part of the match that you want to extract. If the regex does not match the source, the result of the extraction will be an empty value. - In SINGLEREPLACE mode, the regex also needs to match the entire source. `subgroup` selects the n-th capturing group that is replaced with the content of `replacementtext`. If the regex does not match the source, the result of the replacement will be the source itself. - In REPLACEALL mode, the regex is applied repeatedly to find all occurrences within the source that match. Each matching occurrence is replaced with the value in `replacementtext`. In this mode, the configuration is rejected if `subgroup` is set. If the regex does not match the source, the result of the replacement will be the source itself. | | `subgroup` | `int` | If your regex contains capturing groups, use this field to determine the group that you want to select. Defaults to 0. If set in `EXTRACT` and `SINGLEREPLACE` modes, the subgroup represents the capturing group that you want to extract or replace in the source. The configuration is rejected if you set subgroup to a non-zero value when using thev `REPLACEALL` mode. | | `replacementText` | | The value `replacementtext` is used to format the substitution for matched sequences in in an input string. This value is only legal in `SINGLEREPLACE` and `REPLACEALL` modes. - In `SINGLEREPLACE` mode, the `subgroup` selects the n-th capturing group, which represents the value that you want to replace with the string provided in `replacementtext`. - In `REPLACEALL` mode, each sequence that matches the specified regex in the input is replaced with the value in`replacementtext`. The `replacementtext` can include special syntax, such as $1, $2, etc., to refer to capturing groups within the regular expression. The value that is specified in `replacementtext` is treated as a string, and is passed to `std::regexreplace` as the replacement string. For more informatino, see https://en.cppreference.com/w/cpp/regex/regex_replace. | | `mode` | | The mode of operation for the extraction. Defaults to EXTRACT. | The mode of operation for the extraction. | Name | Description | | -- | -- | | `EXTRACT` | Default mode. Extract the content of a specified capturing

In this mode, `subgroup` selects the n-th capturing group, which represents the value that you want to extract. | | `SINGLEREPLACE` | Replace the content of a specified capturing group. In this mode, `subgroup` selects the n-th capturing group, which represents the value that you want to replace with the string provided in `replacementtext`. Note: `replacement_text` must be set for this mode. | | `REPLACEALL` | Replace all regex matches with the value provided in `replacementtext`. Note: `replacement_text` must be set for this mode. Note: The configuration fails if `subgroup` is set to a non-zero value. Note: restrictions on the regex are different for this mode. See the regex field for more details. | Defines a transformation template. ```yaml "advancedTemplates": bool "extractors": map<string, .transformation.options.gloo.solo.io.Extraction> "headers": map<string, string> "headersToAppend": []transformation.options.gloo.solo.io.TransformationTemplate.HeaderToAppend "headersToRemove": []string "body": .transformation.options.gloo.solo.io.InjaTemplate "passthrough": .transformation.options.gloo.solo.io.Passthrough "mergeExtractorsToBody": .transformation.options.gloo.solo.io.MergeExtractorsToBody "parseBodyBehavior": .transformation.options.gloo.solo.io.TransformationTemplate.RequestBodyParse "ignoreErrorOnParse": bool "dynamicMetadataValues": []transformation.options.gloo.solo.io.TransformationTemplate.DynamicMetadataValue "escapeCharacters": .google.protobuf.BoolValue ``` | Field | Type | Description | | -- | - | -- | | `advancedTemplates` | `bool` | If set to true, use JSON pointer notation (e.g. "time/start") instead of dot notation (e.g. "time.start") to access JSON elements. Defaults to false. Please note that, if set to 'true', you will need to use the `extraction` function to access extractors in the template (e.g. '{{ extraction("myextractor") }}'); if the default value of 'false' is used, extractors will simply be available by their name (e.g. '{{ myextractor }}'). | | `extractors` | `map<string, .transformation.options.gloo.solo.io.Extraction>` | Use this attribute to extract information from the request. It consists of a map of strings to extractors. The extractor will defines which information will be extracted, while the string key will provide the extractor with a name. You can reference extractors by their name in templates, e.g. "{{ my-extractor }}" will render to the value of the "my-extractor" extractor. | | `headers` | `map<string, string>` | Use this attribute to transform request/response headers. It consists of a map of strings to templates. The string key determines the name of the resulting header, the rendered template will determine the value. Any existing headers with the same header name will be replaced by the transformed header. If a header name is included in `headers` and `headerstoappend`, it will first be replaced the template in `headers`, then additional header values will be appended by the templates defined in `headerstoappend`. For example, the following header transformation configuration: ```yaml headers: x-header-one: {"text": "first {{inja}} template"} x-header-one: {"text": "second {{inja}} template"} headersToAppend: - key: x-header-one value: {"text": "first appended {{inja}} template"} - key: x-header-one value: {"text": "second appended {{inja}} template"} ``` will result in the following headers on the HTTP message: ``` x-header-one: first inja template x-header-one: first appended inja template x-header-one: second appended inja template ```. | | `headersToAppend` | | Use this attribute to transform request/response headers. It consists of an array of string/template objects. Use this attribute to define multiple templates for a single header. Header template(s) defined here will be appended to any existing headers with the same header name, not replace existing ones. See `headers` documentation to see an example of usage. | | `headersToRemove` | `[]string` | Attribute to remove headers from requests. If a header is present multiple times, all instances of the header will be removed. | | `body` | | Apply a template to the body. Only one of `body`, `passthrough`, or `mergeExtractorsToBody` can be set. | | `passthrough` | | This will cause the transformation filter not to buffer the

Use this setting if the response body is large and you don't need to transform nor extract information from it. Only one of `passthrough`, `body`, or `mergeExtractorsToBody` can be set. | | `mergeExtractorsToBody` | | Merge all defined extractors to the request/response body. If you want to nest elements inside the body, use dot separator in the extractor name. Only one of `mergeExtractorsToBody`, `body`, or `passthrough` can be set. | | `parseBodyBehavior` | | Determines how the body will be parsed. Defaults to ParseAsJson. | | `ignoreErrorOnParse` | `bool` | If set to true, Envoy will not throw an exception in case the body parsing fails. | | `dynamicMetadataValues` | | Use this field to set Dynamic Metadata. | | `escapeCharacters` | | Use this field to set Inja behavior when rendering strings which contain characters that would need to be escaped to be valid JSON. Note that this sets the behavior for the entire transformation. Use raw_strings function for fine-grained control within a template. | Defines a header-template pair to be used in `headerstoappend` ```yaml "key": string "value": .transformation.options.gloo.solo.io.InjaTemplate ``` | Field | Type | Description | | -- | - | -- | | `key` | `string` | Header name. | | `value` | | Apply a template to the header value. | Defines an [Envoy Dynamic Metadata](https://www.envoyproxy.io/docs/envoy/latest/configuration/advanced/wellknowndynamic_metadata) entry. ```yaml "metadataNamespace": string "key": string "value": .transformation.options.gloo.solo.io.InjaTemplate ``` | Field | Type | Description | | -- | - | -- | | `metadataNamespace` | `string` | The metadata namespace. Defaults to the filter namespace. | | `key` | `string` | The metadata key. | | `value` | | A template that determines the metadata value. | Determines how the body will be parsed. | Name | Description | | -- | -- | | `ParseAsJson` | Will attempt to parse the request/response body as JSON | | `DontParse` | The request/response body will be treated as plain text | Defines an that will be rendered by Gloo. In addition to the core template functions, the Gloo transformation filter defines the following custom functions: header(header_name): returns the value of the header with the given name. extraction(extractor_name): returns the value of the extractor with the given name. env(envvarname): returns the value of the environment variable with the given name. body(): returns the request/response body. context(): returns the base JSON context (allowing for example to range on a JSON body that is an array). requestheader(headername): returns the value of the request header with the given name. Use this option when you want to include request header values in response transformations. base64_encode(string): encodes the input string to base64. base64_decode(string): decodes the input string from base64. substring(string, startpos, substringlen): returns a substring of the input string, starting at `startpos` and extending for `substringlen` characters. If no `substringlen` is provided or `substringlen` is <= 0, the substring extends to the end of the input string. ```yaml "text": string ``` | Field | Type | Description | | -- | - | -- | | `text` | `string` | | ```yaml ``` | Field | Type | Description | | -- | - | -- | ```yaml ``` | Field | Type | Description | | -- | - | -- | ```yaml "addRequestMetadata": bool ``` | Field | Type | Description | | -- | - | -- | | `addRequestMetadata` | `bool` | When transforming a request, setting this to true will additionally add "queryString", "queryStringParameters", "multiValueQueryStringParameters", "httpMethod", "path", and "multiValueHeaders" to the body. | <!-- Start of HubSpot Embed Code --> <script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/5130874.js"></script> <!-- End of HubSpot Embed