BaseContentApiModule
Supported versions
Supported Cortex XSOAR versions: 6.8.0 and later.
BaseContentApiModule#
Base classes for building robust Cortex integrations with user-friendly validation, common connection settings, and centralized execution configuration.
Table of Contents#
Overview#
This API module provides foundational classes that integrations can use to:
Validate configuration parameters and command arguments with user-friendly error messages
Manage common connection settings (proxy, SSL verification).
Centralize execution configuration to minimize redundant system calls.
These classes work seamlessly with ContentClient from ContentClientApiModule to provide a complete foundation for building production-ready integrations.
Key Features#
| Feature | Description |
|---|---|
| User-Friendly Validation | Pydantic-based validation with clear, actionable error messages. |
| Common Connection Settings | Standardized proxy and SSL verification parameters. |
| Centralized Configuration | Single entry point for command, params, args, and last_run. |
| Type Safety | Full type hints and validation for integration parameters. |
| Minimal Boilerplate | Code streamlining with reduced redundant demisto class calls. |
Installation#
Import the module in your integration:
Quick Start#
Basic Example#
Classes#
ContentBaseModel#
Base Pydantic model with enhanced validation error formatting.
Features#
- Catches
ValidationErrorexceptions from Pydantic - Formats validation errors in a user-friendly way
- Raises
DemistoExceptionwith clear, readable error messages - Ignores extra fields automatically
- Supports field aliases for parameter name mapping
Usage#
String Representation#
BaseParams#
Base class for integration parameters with common connection settings.
Attributes#
| Attribute | Type | Default | Description |
|---|---|---|---|
insecure | bool | False | Whether to skip SSL certificate verification |
proxy | bool | False | Whether to use system proxy settings |
verify | bool (property) | not insecure | SSL verification setting (computed) |
Usage#
BaseExecutionConfig#
Centralized entry point for integration execution that holds commands, parameters, arguments, and last_run.
Features#
Contains all the information needed to execute a command.
Centralizes
demistoclass usages to avoid redundant system calls.Provides type-safe access to configuration via properties.
Automatically retrieves last_run for fetch commands.
Supports both regular fetch and fetch-assets commands.
Attributes#
| Attribute | Type | Description |
|---|---|---|
_raw_command | str | The command being executed. |
_raw_params | dict | Raw integration parameters dictionary. |
_raw_args | dict | Raw command arguments dictionary. |
_raw_last_run | dict | State from previous fetch execution. |
_raw_assets_last_run | dict | State from previous fetch-assets execution. |
Usage#
Complete Integration Example#
The following is an end-to-end example of a production-ready integration using the BaseContentApiModule with ContentClient:
API Reference#
ContentBaseModel#
Base Pydantic model with user-friendly validation error formatting.
Methods#
| Method | Description |
|---|---|
__init__(**data) | Initialize model with validation. |
__str__() | String representation using aliases. |
__repr__() | Representation using aliases. |
dict(by_alias=True) | Convert to dictionary. |
Configuration#
| Setting | Value | Description |
|---|---|---|
extra | Extra.ignore | Ignore extra fields not defined in model. |
allow_population_by_field_name | True | Allow both field names and aliases. |
Example#
BaseParams#
Base class for integration parameters with common connection settings.
Attributes#
| Attribute | Type | Default | Description |
|---|---|---|---|
insecure | bool | False | Skip SSL certificate verification. |
proxy | bool | False | Use system proxy settings. |
verify | bool (property) | not insecure | SSL verification (computed). |
Example#
BaseExecutionConfig#
Centralized entry point for integration execution.
Attributes#
| Attribute | Type | Description |
|---|---|---|
_raw_command | str | Current command being executed. |
_raw_params | dict | Raw integration parameters. |
_raw_args | dict | Raw command arguments. |
_raw_last_run | dict | State from previous fetch. |
_raw_assets_last_run | dict | State from previous the fetch-assets execution. |
Properties#
| Property | Type | Description |
|---|---|---|
command | str | The current command name. |
Example#
Dependencies#
- pydantic: Data validation and settings management.
- CommonServerPython: Common integration utilities.
- demistomock: Local debugging support.
Best Practices#
- Inherit from ContentBaseModel for parameter and argument classes to get user-friendly error messages.
- Inherit from BaseParams to automatically include common connection settings in integration parameters.
- Create one ExecutionConfig instance in main() to minimize redundant system calls.
- Define properties in the ExecutionConfig subclass for each command's arguments and for fetch last run.
- Use validators to add custom validation logic and data cleaning.
- Document your models with docstrings and type hints** for better IDE and linter support.
Integration Example#
See the Hello World v2 integration for a complete example of using these base classes in a production integration.
Related Modules#
- ContentClientApiModule: High-performance HTTP client with retry logic, rate limiting, and authentication.
- CommonServerPython: Core utilities and helper functions for Cortex integrations.