-
Notifications
You must be signed in to change notification settings - Fork 6
Slice Command
The slice command extracts specific sections (entity types) from a Gateway configuration bundle, creating a new bundle with only the selected entities. This is useful for creating focused bundles, removing unwanted entities, or preparing selective deployments.
graphman slice --input <input-file> [--sections <section> <section>...]
[--output <output-file>]
[--filter.<section>.<field-name> [<matching-criteria>.]<field-value>]| Parameter | Description |
|---|---|
--input |
Input bundle file to slice |
| Parameter | Description | Default |
|---|---|---|
--sections |
One or more section names to include/exclude | None (empty bundle) |
--output |
Output file for the sliced bundle | Standard output (console) |
--filter.<section>.<field> |
Filter entities within sections | None |
Sections refer to entity types using their plural names:
| Section Name | Entity Type |
|---|---|
services |
Web Services |
policies |
Policies |
policyFragments |
Policy Fragments |
folders |
Folders |
keys |
Private Keys |
trustedCerts |
Trusted Certificates |
jdbcConnections |
JDBC Connections |
jmsDestinations |
JMS Destinations |
clusterProperties |
Cluster Properties |
scheduledTasks |
Scheduled Tasks |
encassConfigs |
Encapsulated Assertions |
| Section | Meaning |
|---|---|
* |
All sections in the bundle |
-<section> |
Exclude the specified section |
+<section> |
Explicitly include the section (optional prefix) |
- Sections are processed in the order specified
- Use
*to include all sections first - Use
-sectionto exclude specific sections - Sections not listed are excluded by default
- Filters are applied after section selection
- Filters use the same syntax as the export command
- Multiple filters are combined with AND logic
Extract only services and policies:
graphman slice --input full-bundle.json --sections services policies --output services-policies.jsonInclude everything except folders and cluster properties:
graphman slice --input bundle.json --sections "*" -folders -clusterProperties --output filtered.jsonExtract only services:
graphman slice --input bundle.json --sections services --output services-only.jsonExtract services in a specific folder:
graphman slice --input bundle.json --sections services \
--filter.services.folderPath.eq /APIs/External \
--output external-apis.jsonExtract enabled services only:
graphman slice --input bundle.json --sections services \
--filter.services.enabled.eq true \
--output enabled-services.jsonInclude all, then exclude several sections:
graphman slice --input bundle.json \
--sections "*" -scheduledTasks -auditConfigurations -emailListeners \
--output deployment-bundle.jsonCombine multiple filter criteria:
graphman slice --input bundle.json --sections services \
--filter.services.enabled.eq true \
--filter.services.folderPath.regex "^/Production" \
--output prod-enabled-services.jsonDeploy only specific entity types:
# Extract services and policies for deployment
graphman slice --input full-config.json --sections services policies --output deployment.json
graphman import --input deployment.json --gateway prodRemove keys and certificates before sharing:
graphman slice --input bundle.json \
--sections "*" -keys -trustedCerts -passwords \
--output shareable-config.jsonExtract environment-specific entities:
graphman slice --input bundle.json \
--sections clusterProperties jdbcConnections jmsDestinations \
--output env-config.jsonExtract reusable policies and fragments:
graphman slice --input bundle.json \
--sections policies policyFragments \
--filter.policies.folderPath.eq /Library \
--output policy-library.jsonDeploy entities in stages:
# Stage 1: Infrastructure
graphman slice --input bundle.json --sections folders clusterProperties --output stage1.json
# Stage 2: Security
graphman slice --input bundle.json --sections keys trustedCerts --output stage2.json
# Stage 3: Services
graphman slice --input bundle.json --sections services policies --output stage3.jsonIdentify entities for deletion:
graphman slice --input current-config.json \
--sections services \
--filter.services.folderPath.eq /Deprecated \
--output to-delete.jsonExtract comparable sections from different environments:
graphman slice --input dev-config.json --sections services policies --output dev-services.json
graphman slice --input prod-config.json --sections services policies --output prod-services.json
graphman diff --input-source dev-services.json --input-target prod-services.json --output differences.json| Criteria | Description | Example |
|---|---|---|
eq, equals
|
Exact match (default) | --filter.services.name.eq MyService |
neq |
Not equals | --filter.services.enabled.neq false |
regex |
Regular expression | --filter.services.name.regex ^API.* |
gt |
Greater than | --filter.services.version.gt 5 |
lt |
Less than | --filter.services.version.lt 10 |
gte |
Greater than or equals | --filter.services.version.gte 1 |
lte |
Less than or equals | --filter.services.version.lte 5 |
Extract specific services and all their dependencies:
# First, export with dependencies
graphman export --using services --variables.name "MyService" \
--options.excludeDependencies false --gateway prod --output with-deps.json
# Then slice to remove unwanted sections
graphman slice --input with-deps.json \
--sections services policies folders keys \
--output deployment-ready.jsonApply filters across all sections:
graphman slice --input bundle.json --sections "*" \
--filter.*.folderPath.regex "^/Production" \
--output production-entities.jsonDifferent filters for different sections:
graphman slice --input bundle.json \
--sections services policies \
--filter.services.enabled.eq true \
--filter.policies.policyType.eq "Include" \
--output filtered.json- Section names are case-sensitive and must use plural form
- Unknown section names generate warnings but don't cause errors
- Empty sections are included in output (as empty arrays)
- The output bundle is automatically sorted
- Filters are applied after section selection
- Use
schemacommand to see all available section names - Bundle properties are preserved in the output
- The
*section must be specified first if used with exclusions
Sections appear in the output in the standard order:
- Entity sections (alphabetically by plural name)
- Bundle properties (always last)
- combine: Merge multiple bundles
- export: Export with built-in filtering
- diff: Compare sliced bundles
- explode: Break down sliced bundles
- Use descriptive output names that indicate what was sliced
- Validate sliced bundles before importing
- Document section selections in deployment procedures
- Test sliced bundles in non-production first
- Combine with filters for precise entity selection
-
Use
*with exclusions to simplify complex selections -
Check section names using the
schemacommand - Preserve dependencies when slicing for deployment
#!/bin/bash
# Export from development
graphman export --gateway dev --output dev-full.json
# Slice for production deployment
graphman slice --input dev-full.json \
--sections services policies folders \
--filter.services.folderPath.regex "^/Release" \
--output prod-deployment.json
# Validate
graphman validate --input prod-deployment.json
# Deploy
graphman import --input prod-deployment.json --gateway prod#!/bin/bash
DATE=$(date +%Y%m%d)
# Full backup
graphman export --gateway prod --output backups/full-$DATE.json
# Security backup
graphman slice --input backups/full-$DATE.json \
--sections keys trustedCerts \
--output backups/security-$DATE.json
# Services backup
graphman slice --input backups/full-$DATE.json \
--sections services policies policyFragments \
--output backups/services-$DATE.jsonwarn: unknown section mySection
Solution: Check section name spelling and use plural form. Use graphman schema to list valid sections.
If output is empty, ensure:
- Section names are correct
- Sections exist in the input bundle
- Filters aren't too restrictive
Verify:
- Filter syntax:
--filter.<section>.<field>.<criteria> <value> - Field names match entity structure
- Matching criteria is valid