# Version is the version of the idl.
version = 0

# Name is the type name of the operation to generate.
name = "ExampleOperation"

[properties]
# Built-ins are fields that are built into the IDL language. Generators know how to create and
# document setters for them and transform them into BSON. A built-in can be default, in which case
# it can be explicitly disabled. If a built-in is not default, it must be explicitly enabled.

# Disabled is an array of default built-ins to disable. The default fields are: database,
# deployment, selector, command monitor, client session, cluster clock, and collection. The database
# and deployment built-ins should not be disabled because removal will result in a command that will
# always error.
disabled = ["selector"]

# Enabled is an array of non-default built-ins to enable. The available fields are: read preference,
# read concern, and write concern.
enabled = ["read preference", "read concern"]

# Retryable is a table with two key/value pairs: Mode and Type. Mode specifies the default mode that
# will be used for retrying. The generator will add a setter for the mode so the user can override
# it. The mode can be one of: once, once per command, or context. Type is the kind of operation that
# is being retried. The type field can be either writes or reads. If the Mode field is set, the Type
# field must also be set.
retryable = {mode = "once per command", type = "writes"}

# Batches enables batch splitting for this operation. It's value is the name of a request field that
# will be used for batch splitting. If a request field named "ordered" is defined, it will be used
# to determine ordering for batch commands. The type of the field must be "array".
batches = "examples"

# Legacy specifies that this operation will execute a legacy command when the max wire version of
# the server is below a specific number. The three values for legacy are: find, getMore, and
# killCursors.
legacy = "none"

# MinimumWriteConcernWireVersion specifies the minimum wire version required to add a write concern to
# this operation.
MinimumWriteConcernWireVersion = 4

# MinimumReadConcernWireVersion specifies the minimum wire version required to add a read concern to
# this operation.
MinimumReadConcernWireVersion = 4

# command defines specific information about the command that will be constructed.
[command]
# name is the command name, which will be the first field of the BSON document representing the
# command.
name = "example"

# The parameter specifies which request field should be used to fill in this value.
parameter = "collection"

# Database, when true, indicates that if the parameter field is empty, the command is being run on a
# database and should use the value 1 when running the command.
database = true

# Request is a map of fields that are parameters for the operation. A setter will be generated for
# each and they will be added to the request command sent to the server.
[request]

# The name of the table within the request table will be used internally in the generated command.
[request.examples]
# Type specifies the type to use. For now these map directly to BSON types. The currently supported
# types are: value, double, string, document, binary, boolean, int32, and int64.
type = "document"
# Slice, when true, indicates that the field is a slice of the type.
slice = true
# Constructor, when true, indicates that this field is a parameter of the constructor for the
# operation.
constructor = true
# Variadic only has an effect if constructor is also true. When true, variadic indicates that the
# parameter for this field should be last and should be variadic.
variadic = true
# MinWireVersion specifies the minimum wire version required to add this field to a command.
minWireVersion = 5
# Documentation is the documentation comment that will be used for the setter. This is used verbatim
# so the first word should be a capitalized version of the field name.
documentation = """
Examples adds example documents to this operation. They will be inserted into the
collection specified"""

[request.ordered]
type = "boolean"
documentation = """
Ordered sets ordered. If true, when a write fails, the operation will return the error, when
false write failures do not stop execution of the operation."""

# Response is a map of fields that form the structure of the expected response. Metadata, like the
# cluster and operation times, should not be included unless they are required to be provided to the
# caller. This table is used to generate a type that will be returned after running the command. If
# the operation supports batches, a single instance of the generated type will be created and
# updated with the responses from subsequent commands.
[response]
# Name is the name that is used for the generated type.
name = "ExampleResult"

# Type indicates what type this response is. This can only be set if name is not set. The only valid
# value at this time is batch cursor.
# type = "batch cursor"

# The name of the table within the response table will be the name of the field in the created type.
[response.field.n]
# Type specifies the type to use for the field. For now these map directly to BSON types.
type = "int64"
# Documentation is the documentation comment that will be added above the field in the generated
# type. This is used verbatim.
documentation = "Number of examples created."
