For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Open sourceSupportFAQsDocs Home
DocumentationCommand referenceRelease notes
DocumentationCommand referenceRelease notes
  • Command reference
    • iagctl cert-gen
    • iagctl completion
      • create decorator
      • create executable-object
      • create registry
      • create repository
      • create secret
      • create user
    • iagctl login
    • iagctl runner
    • iagctl server
    • iagctl version
LogoLogo
Open sourceSupportFAQsDocs Home
On this page
  • Syntax
  • JSON Schema overview
  • Examples
  • Create a decorator from a file
  • Create a decorator from inline JSON
  • Options
  • Options inherited from parent commands
Command referenceiagctl create

iagctl create decorator

Was this page helpful?
Previous

iagctl create executable-object

Next
Built with

Create a new decorator.

For detailed information on creating and using decorators, see Validate and limit service inputs with decorators.

The iagctl create decorator command creates a decorator in your gateway data store. Decorators use JSON Schema to validate the inputs passed to a service at runtime, letting you control exactly which inputs a service accepts.

Syntax

$iagctl create decorator <decorator-name> --schema <string> [flags]

JSON Schema overview

Decorators rely on a JSON Schema document to define and validate service inputs. Each service input corresponds to a property in the schema’s properties object.

The following fields are particularly relevant in IAG:

FieldDescription
typeThe data type for the input. Accepts one of the following values: string, number, integer, object, array, boolean, or null. For Python script services, properties defined as boolean use bare --set key syntax at runtime rather than --set key=value. For more information, see Boolean properties in Python script services.
enumA limited set of accepted values for the input.

For additional validation options, see the JSON Schema website.

For example, consider a gateway service that takes two inputs: interface and device_type. The following JSON Schema document validates those inputs:

1{
2 "$id": "root",
3 "$schema": "https://json-schema.org/draft/2020-12/schema",
4 "type": "object",
5 "properties": {
6 "interface": {
7 "type": "string",
8 "description": "The interface to update"
9 },
10 "device_type": {
11 "type": "string",
12 "description": "The type of device",
13 "enum": ["ios", "eos", "nxos"]
14 }
15 },
16 "required": [
17 "interface",
18 "device_type"
19 ],
20 "additionalProperties": false
21}

When you specify this decorator on a service, it validates that the interface and device_type inputs are passed correctly in the iagctl run service request:

$iagctl run pythonscript example-service-with-deco \
>--set interface=1/1/1 \
>--set device_type=eos

Examples

Create a decorator from a file

To create a decorator from a JSON Schema file called my_decorator.json, run the following command:

$iagctl create decorator my-decorator \
>--schema @my_decorator.json

You typically format schema files as JSON, but IAG also accepts YAML.

Create a decorator from inline JSON

You can also specify the JSON Schema content directly in the command. Wrap your JSON in single quotes:

$iagctl create decorator my-decorator \
>--schema '{"$id":"root","$schema":"https://json-schema.org/draft/2020-12/schema","type":"object","properties":{"interface":{"type":"string"}}}'

Options

$ --description string A brief description of the decorator
$ -h, --help Help for decorator
$ --schema string The schema of the decorator. Accepts inline JSON or a file reference prefixed with '@'.
$ --tag stringArray Metadata tag(s) to associate with the decorator

Options inherited from parent commands

$ --profile string Specify the client profile to use (case-insensitive, defaults to [client] section)
$ --config string Path to the configuration file
$ --raw Display the result of the command in raw format
$ --verbose Enable verbose output