{
  "$schema": "http://json-schema.org/draft-07/schema#",
  "$id": "https://www.krakend.io/schema/v2.11/backend/grpc.json",
  "title": "gRPC backend connection",
  "description": "Enterprise only. Handles the communication with a backend using gRPC, after having defined the protocol buffer definitions.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
  "type": "object",
  "properties": {
    "client_tls": {
      "title": "Enable TLS client options",
      "description": "Enables specific TLS connection options when using the gRPC service. Supports all options under [TLS client settings](https://www.krakend.io/docs/service-settings/tls/#client-tls-settings).\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "$ref": "../client_tls.json"
    },
    "disable_query_params": {
      "title": "Disable query parameters",
      "description": "When `true`, it does not use URL parameters (`{placeholders}` in endpoints)  or query strings to fill the gRPC payload to send. If `use_request_body` is not set, or set to `false`, and this option is set to `true`, there will be no input used for the gRPC message to send. That is still a valid option, when we just want to send the message with its default values, or when the input for the gRPC calls is just the [empty message](https://github.com/protocolbuffers/protobuf/blob/main/src/google/protobuf/empty.proto).\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": false,
      "type": "boolean"
    },
    "header_mapping": {
      "title": "Mapping of headers",
      "description": "A dictionary that rename the received header (key) to a new header name (value). If the header starts with `grpc` they will be renamed to `in-grpc-*` as the word is reserved.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "examples": [
        {
          "X-Tenant": "customerid"
        }
      ],
      "type": "object",
      "patternProperties": {
        ".*": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "idle_conn_disconnect_time": {
      "title": "Request naming convention",
      "description": "The maximum time a connection is kept without being used.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": "10m",
      "$ref": "../timeunits.json#/$defs/timeunit",
      "type": "string"
    },
    "input_assume_bytes": {
      "title": "Assume input are bytes",
      "description": "When set to true, when the backend has to fill a bytes field for a grpc protobuf payload to send, first tries to decode the input data (the one coming from either a json body field, a query param or header string) from base64: if it succeeds it fills the field to send with that binary / bytes data. If the incoming field is not a valid base64 decoded field (the one used in jsonpb), it will fill the binary field with the verbatim conversion of the incoming string to bytes.",
      "default": false
    },
    "input_mapping": {
      "title": "Mapping of parameters",
      "description": "A dictionary that converts query string parameters and parameters from `{placeholders}` into a different field during the backend request. When passing parameters using `{placeholder}` the parameter capitalizes the first letter, so you receive `Placeholder`.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "examples": [
        {
          "lat": "where.latitude",
          "lon": "where.longitude"
        }
      ],
      "type": "object",
      "patternProperties": {
        ".*": {
          "type": "string"
        }
      },
      "additionalProperties": false
    },
    "output_duration_as_string": {
      "title": "Output duration types as string",
      "description": "Well-known Duration types (`google.protobuf.Duration`) are returned as a struct containing fields with `seconds` and `nanos` fields (flag set to `false`). Setting this flag to `true` transforms the timestamps into a string representation in seconds.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": false,
      "type": "boolean"
    },
    "output_enum_as_string": {
      "title": "Output enum types as string",
      "description": "Enum types are returned as numeric values (flag set to `false`). Set this flag to `true` to return the string representation of the enum value. For instance, an enum representing allergies, such as `['NUTS', 'MILK', ' SOY', 'WHEAT']` would return a value `SOY` when this flag is `true`, or `2` when `false`.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": false,
      "type": "boolean"
    },
    "output_remove_unset_values": {
      "title": "Output removes unset values",
      "description": "This attribute defines what to do when a field that is declared in the definition does not exist in the backend response. When the flag is `true`, any fields in the definition that are not present in the backend response are removed before returning the content to the user. When the flag is `false` missing fields are returned but set with a zeroed-value depending on its type (zero, nil, false, etc).\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": false,
      "type": "boolean"
    },
    "output_timestamp_as_string": {
      "title": "Output timestamps types as string",
      "description": "Well-known Timestamp types (`google.protobuf.Timestamp`) are returned as a struct containing fields with `seconds` and `nanos` fields (flag set to `false`). Setting this flag to `true` transforms the timestamps into a string representation in RFC3999 format.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": false,
      "type": "boolean"
    },
    "read_buffer_size": {
      "title": "Read buffer size",
      "description": "Specifies the size of the client buffer reading the gRPC communication in bytes. If the value is unset, or `0`, it uses its default (32KB). Use a negative value to disable the buffer, and if you do there won't be memory pre-allocation to read. To determine the right number, calculate the average size of the responses the gRPC client will receive.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "examples": [ 32768, 8192, -1 ],
      "type": "number"
    },
    "request_naming_convention": {
      "title": "Request naming convention",
      "description": "Defines the naming convention used to format the request. Applies to query strings and JSON field names. By default, the gateway uses `snake_case` which makes use of the standard `encoding/json` package, while when you choose `camelCase` the `protobuf/encoding` deserialization is used instead.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": "snake_case",
      "enum": [ "camelCase", "snake_case" ]
    },
    "response_naming_convention": {
      "title": "Response naming convention",
      "description": "Defines the naming convention used to format the returned data. By default, the gateway uses `snake_case` which makes use of the standard `encoding/json` package, while when you choose `camelCase` the `protobuf/encoding` deserialization is used instead.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": "snake_case",
      "enum": [ "camelCase", "snake_case" ]
    },
    "use_alternate_host_on_error": {
      "title": "Use alternate host on error",
      "description": "When `true`, before sending a message to a host, it checks if the connection status is in a \"transient failure\" or \"failure\" state and tries to use a different host (from the service discovery or randomly from the list of hosts). If the connection is in a valid state, but an error happens when sending the gRPC message, it also tries to use a different host to retry sending the message. Depending on the host list, the retry attempts may go to the same host initially in a \"bad state\".\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "type": "boolean"
    },
    "use_request_body": {
      "title": "Use body",
      "description": "Enables the use of the sent body to fill the gRPC request. Take into account that when you set this flag to `true` a body is expected, and this body is **consumed** in the first backend. If the endpoint that uses this gRPC backend has additional backends (either gRPC or HTTP) that also expect to consume the payload, these requests might fail.\n\nSee: https://www.krakend.io/docs/enterprise/backends/grpc/",
      "default": false,
      "type": "boolean"
    }
  },
  "patternProperties": {
    "^[@$_#]": {}
  },
  "additionalProperties": false
}
