JSON API
CCM provides a STDIN/STDOUT API for managing resources programmatically. This enables integration with external languages, allowing you to build DSLs in Ruby, Perl, Python, or any language that can execute processes and handle JSON or YAML.
Overview
The API uses a simple request/response pattern:
- Send a request to
ccm ensure api pipevia STDIN - Receive a response on STDOUT
Both JSON and YAML formats are supported for requests. The response format is always JSON, but can be explicitly set to YAML using --yaml.
Command
| Flag | Description |
|---|---|
--yaml | Output response in YAML format instead of JSON |
--noop | Dry-run mode; report what would change without making changes |
--facts <file> | Load additional facts from a YAML file |
--data <file> | Load Hiera-style data from a YAML file |
Request Format
Requests must include a protocol identifier, resource type, and properties.
Note
JSON Schemas for these requests and responses are available at resource_ensure_request.json and resource_ensure_response.json.
JSON Request
YAML Request
Request Fields
| Field | Required | Description |
|---|---|---|
protocol | Yes | Must be io.choria.ccm.v1.resource.ensure.request |
type | Yes | Resource type example package |
properties | Yes | Resource properties (varies by type) |
Response Format
Responses include a protocol identifier and either a state object (on success) or an error message.
For the full response structure, see ResourceEnsureApiResponse in the Go documentation. The state field contains a TransactionEvent.
Successful Response
Error Response
Examples
Install a Package
Manage a Service
Create a File
Dry-Run Mode
Resource Types
For detailed information about each resource type and its properties, see the Resource Documentation