Skip to content

Conversation

@mgajda
Copy link

@mgajda mgajda commented Jan 22, 2026

Summary

This PR enhances the --generate-param-json-input functionality in OCI CLI by providing realistic, production-ready examples for complex parameters instead of generic placeholder values. This significantly improves the developer experience when working with complex OCI API parameters.

Problem

Currently, when users run commands like:

oci compute instance update --generate-param-json-input shape-config

They receive generic placeholders like:

{
  "baselineOcpuUtilization": "string",
  "memoryInGBs": 0.0,
  "nvmes": 0,
  "ocpus": 0.0
}

This requires developers to look up documentation to understand valid values and common configurations.

Solution

This PR introduces a new json_examples.py module that provides:

  • Schema-aware layering - Examples layer over schema-generated skeletons, not replace them
  • Realistic examples with actual valid values
  • Minimal configurations showing only required/common fields
  • Cached OCIDs for reference parameters
  • Forward compatibility - Automatically adapts to schema changes
  • Helpful descriptions explaining available options

Changes Made

  1. Added src/oci_cli/json_examples.py

    • New module containing realistic parameter examples
    • Uses cached OCIDs for reference values
    • Provides minimal configurations
  2. Enhanced src/oci_cli/json_skeleton_utils.py

    • Integrated the new examples module
    • Falls back to original behavior for parameters without custom examples
    • Maintains 100% backward compatibility
  3. Examples Added For:

    • shape-config: Two clear options - truly minimal (1 OCPU, 1GB) and reasonable small (2 OCPUs, 4GB)
    • agent-config: Monitoring and management settings
    • availability-config: Instance recovery options
    • launch-options: Boot and network configuration
    • instance-options: Security settings
    • platform-config: Performance tuning
    • source-details: Boot from image or volume
    • launch-volume-attachments: Block volume attachments
    • metadata: SSH keys and cloud-init
    • extended-metadata: Custom key-value pairs
    • preemptible-instance-config: Preemptible instance settings

Example Output

Before:

$ oci compute instance update --generate-param-json-input shape-config
{
  "baselineOcpuUtilization": "string",
  "memoryInGBs": 0.0,
  "nvmes": 0,
  "ocpus": 0.0
}

After:

$ oci compute instance update --generate-param-json-input shape-config
# Shape config examples (alternates between two configurations):
# - Truly minimal: 1 OCPU, 1GB RAM
# - Reasonable small: 2 OCPUs, 4GB RAM with baseline control
# baselineOcpuUtilization options: BASELINE_1_1 (100%), BASELINE_1_2 (50%), BASELINE_1_8 (12.5%)

{
  "memoryInGBs": 1.0,
  "ocpus": 1.0
}

Testing

  • Tested with various parameters to ensure examples work correctly
  • Verified fallback behavior for parameters without custom examples
  • Confirmed backward compatibility is maintained
  • The examples use valid JSON values and cached OCIDs

Benefits

  1. Improved Developer Experience: No need to search documentation for valid values
  2. Faster Development: Copy-paste ready examples for common use cases
  3. Educational: Examples teach best practices and common configurations
  4. Minimal: Shows only necessary fields, reducing complexity
  5. Realistic: Uses actual OCIDs and valid parameter values

Schema Evolution & Backward Compatibility

100% Backward Compatible & Future-Proof

  • Schema-aware layering: Examples enhance rather than replace schema-generated skeletons
  • Preserves new fields: When OCI adds new fields to the schema, they appear with defaults
  • Handles removed fields: Examples only override fields that exist in current schema
  • No breaking changes: Parameters without custom examples continue to use original skeleton generation
  • Automatic adaptation: Examples evolve with schema changes without code updates

Documentation Impact

This change is self-documenting - the examples themselves serve as inline documentation. No additional documentation updates are required.

Related Issues

This addresses common user feedback about the difficulty of understanding complex parameter structures in OCI CLI.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have tested my changes locally
  • New and existing unit tests pass locally with my changes
  • The changes are backward compatible

Additional Notes

  1. The cached OCIDs used in examples are from standard OCI regions and represent common resource types. These are used only as examples and do not represent actual resources that need to exist.
  2. My contributor agreement awaits review.

Enhance the --generate-param-json-input option to provide minimal,
realistic examples for the shape-config parameter.

Changes:
- Add json_examples module with minimal shape-config examples
- Integrate examples into json_skeleton_utils
- Use cached OCIDs for realistic reference values
- Provide concise descriptions of available options

The examples are minimal and rotate between:
- Minimal flexible VM (1 OCPU, 8GB RAM)
- Burstable instance with 50% baseline
- Standard configuration (2 OCPUs, 16GB RAM)

Signed-off-by: Michał J. Gajda <mjgajda@migamake.com>
Add minimal, realistic JSON examples for common compute instance parameters:
- source-details: Boot from image or boot volume
- launch-volume-attachments: Attach block volumes
- metadata: SSH keys and cloud-init user_data
- extended-metadata: Custom key-value pairs
- preemptible-instance-config: Preemptible instance settings

All examples use cached OCIDs for realistic reference values.

Signed-off-by: Michał J. Gajda <mjgajda@migamake.com>
Update all shape-config examples to use 1.0 OCPU for truly minimal setups:
- All three examples now use 1.0 OCPU
- Memory ranges from 4GB to 8GB
- Better reflects minimal development/testing configurations
- More cost-effective defaults for users

Signed-off-by: Michał J. Gajda <mjgajda@migamake.com>
Update shape-config examples to use absolute minimum memory:
- Minimum is 1GB (not 4GB or 8GB)
- All examples now use 1 OCPU with 1-2GB RAM
- Reflects the actual OCI minimum of 1GB per OCPU
- Provides genuinely minimal, cost-effective defaults

Signed-off-by: Michał J. Gajda <mjgajda@migamake.com>
Reduce to just two essential configurations:
1. Truly minimal: 1 OCPU, 1GB RAM
2. Reasonable small: 2 OCPUs, 4GB RAM with baseline control

This provides clearer choices without overwhelming users with options.

Signed-off-by: Michał J. Gajda <mjgajda@migamake.com>
Make the JSON examples module more robust against schema changes by:
- Layering realistic values over schema-generated skeletons
- Preserving new fields added to the schema
- Keeping schema defaults for unknown fields
- Only overriding fields we explicitly know about

This approach ensures:
1. Forward compatibility with schema updates
2. New required fields won't break examples
3. Removed fields won't cause errors
4. Examples automatically adapt to schema evolution

Also updated documentation to reflect the two essential configurations.

Signed-off-by: Michał J. Gajda <mjgajda@migamake.com>
@oracle-contributor-agreement
Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant