Skip to content

Add resource_group_id parameter support to create_entity method #55

@egallis31

Description

@egallis31

Add resource_group_id parameter support to create_entity method

Description

The JupiterOne Python API client's create_entity method is missing support for the resource_group_id parameter, which is available in the underlying GraphQL CREATE_ENTITY mutation. This limitation forces users to manage resource group assignment separately or use direct GraphQL calls instead of using the convenient client method.

Current Behavior

The create_entity method only accepts these parameters:

  • entity_type (required)
  • entity_class (required)
  • entity_key (required)
  • properties (optional)

When attempting to create an entity that requires assignment to a specific resource group, users must manage resource group assignment through separate operations or use direct GraphQL mutations.

Expected Behavior

The create_entity method should accept a resource_group_id parameter to match the capabilities of the underlying GraphQL API.

Code Example

Current limitation (no resource group assignment):

# Current - no resource group assignment during creation
entity = j1_client.create_entity(
    entity_type="test_type",
    entity_class="TestClass", 
    entity_key="test_key",
    properties={
        "name": "My Entity",
        "description": "Entity description"
    }
)
# Resource group must be assigned separately or through other means

Desired client method usage:

# What we want to be able to do
entity = j1_client.create_entity(
    entity_type="test_type",
    entity_class="TestClass",
    entity_key="test_key", 
    properties={
        "name": "My Entity",
        "description": "Entity description"
    },
    resource_group_id="resource-group-id"  # Add this parameter
)

Inconsistency with Other Methods

Other client methods like create_alert_rule and create_integration_instance already support the resource_group_id parameter, making this omission inconsistent with the rest of the API client.

Example from integration creation method:

# create_integration_instance already supports resource_group_id (v1.5.0+)
integration = j1_client.create_integration_instance(
    instance_name="my-integration",
    instance_description="Integration description",
    resource_group_id="resource-group-id"  # Already supported
)

Impact

This limitation affects:

  • Users who need to organize entities within specific resource groups during creation
  • Automated deployment scripts and CI/CD pipelines that manage resource group assignments
  • Organizations with strict resource group governance requirements
  • Consistency of the API client interface

Proposed Solution

Add resource_group_id as an optional parameter to the create_entity method signature and include it in the GraphQL mutation variables when provided.

Environment

  • JupiterOne Python API Client: v1.5.0
  • Python: 3.8+

Additional Context

This issue was discovered during automated testing for JupiterOne IAM deployment validation, where entities need to be created within specific resource groups for proper access control testing. The inconsistency with other methods (like create_integration_instance which got this feature in v1.5.0) highlighted this gap.

Related Issues

  • Issue #49 - Similar pattern for create_integration_instance method (resolved in v1.5.0)

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions