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 service ansible-playbook
        • create service executable
        • create service opentofu-plan
        • create service python-script
      • create user
    • iagctl login
    • iagctl runner
    • iagctl server
    • iagctl version
LogoLogo
Open sourceSupportFAQsDocs Home
On this page
  • Prerequisites
  • Syntax
  • Usage notes
  • Dependencies
  • Environment variables
  • Decorators
  • Runtime arguments
  • Examples
  • Create a basic Python script service
  • Create a Python script service with all options
  • Options
  • Options inherited from parent commands
Command referenceiagctl createcreate service

iagctl create service python-script

Was this page helpful?
Previous

iagctl create user

Next
Built with

Create a new Python script service.

The iagctl create service python-script command creates a Python script service in the gateway data store. You can then run the service with the iagctl run command. For more information, see Create gateway services.

Consider a Python script in a repository called example-repo with the following directory layout:

$├── README.md
$├── interface-scripts
$│ ├── main.py
$│ └── requirements.txt

To create a service from the script in the interface-scripts directory, specify the repository with --repository, the subdirectory with --working-dir, and the script file with --filename.

Prerequisites

Before you create a Python script service, you need a repository that contains your script.

Syntax

$iagctl create service python-script <service-name> --repository <string> --filename <string> [flags]

Usage notes

Dependencies

If a requirements.txt file exists in the --working-dir, the gateway automatically installs the dependencies into a virtual environment and runs the script within that environment.

Environment variables

Use the --env flag to set environment variables that the gateway applies at runtime. Specify each variable as a key=value pair.

Decorators

You can attach a decorator to the service for input validation at runtime with the --decorator flag. For more information, see iagctl create decorator.

Runtime arguments

For information on how Python scripts read arguments passed at runtime, see iagctl run service python-script.

Examples

Create a basic Python script service

The following example creates a service called my-python-service where the script main.py is at the root of the my-repo repository:

$iagctl create service python-script my-python-service \
>--repository my-repo \
>--filename main.py

Create a Python script service with all options

The following example creates a service that specifies a working directory, a decorator, environment variables, and metadata:

$iagctl create service python-script interface-renamer \
>--repository example-repo \
>--filename main.py \
>--working-dir interface-scripts \
>--decorator my-decorator \
>--description "A Python script to set an interface description" \
>--env key1=value1 \
>--env key2=value2 \
>--tag interfaces

Options

$ --decorator string The decorator to associate with the service.
$ --description string A brief description of the service.
$ --env stringArray Environment variables as key=value pairs. Provide multiple flags for multiple variables.
$ --filename string The Python script file in the repository. Must exist in the working directory. (default "main.py")
$ -h, --help Help for python-script.
$ --repository string The gateway repository that contains the Python script.
$ --tag stringArray Metadata tags to associate with the service.
$ --working-dir string Path to the directory where the script exists, relative to the repository root.

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