Skip to content

Add update_split method to SplitMicroClient for PATCH endpoint #35

@Patryk-Janowski

Description

@Patryk-Janowski

Summary

The Split Admin API supports a PATCH /internal/api/v2/splits/ws/{workspace-id}/{feature-flag-name} endpoint (docs) that allows updating a feature flag's description, tags, and rollout status using JSON Patch operations.

The Python SDK (splitapiclient) does not currently expose this endpoint.

Motivation

We need to programmatically update the rollout status of feature flags. Currently, the only way to do this through the SDK is via the change request workflow (submit_change_request + approve), which:

  • Requires fetching a split definition from a specific environment
  • Rebuilds the full split payload

The PATCH endpoint is much simpler — it operates at the split level (not the environment/definition level) and doesn't require change requests or approvers.

Current client gap

SplitMicroClient has methods for get, list, add, delete, update_description, associate_tags, add_to_environment, and remove_from_environment, but no general update/patch method that maps to the PATCH endpoint.

Proposed changes

1. Add endpoint definition to SplitMicroClient._endpoint

'update': {
    'method': 'PATCH',
    'url_template': 'splits/ws/{workspaceId}/{splitName}',
    'headers': [{
        'name': 'Authorization',
        'template': 'Bearer {value}',
        'required': True,
    }],
    'query_string': [],
    'response': True,
}

2. Add method to SplitMicroClient

def update(self, split_name, workspace_id, data):
    """
    :param split_name: Name of the split to update
    :param workspace_id: Workspace ID
    :param data: List of JSON Patch operations,
        e.g. [{"op": "replace", "path": "/rolloutStatus", "value": {"id": "..."}}]
    """
    response = self._http_client.make_request(
        self._endpoint['update'],
        body=data,
        workspaceId=workspace_id,
        splitName=split_name,
    )
    return Split(response, workspace_id, self._http_client)

3. Add method to Split resource

def update(self, data, apiclient=None):
    """
    Update split via JSON Patch operations.

    :param data: List of JSON Patch operations
    :param apiclient: If this instance wasn't returned by the client,
        the IdentifyClient instance should be passed in order to perform the
        http call

    :returns: Split instance
    :rtype: Split
    """
    imc = require_client('Split', self._client, apiclient)
    return imc.update(self._name, self._workspace_id, data)

Example usage

split_client = get_client({"apikey": "..."})

split = split_client.splits.get("my_flag", "ws-123")

# Update rollout status
split.update(data=[
    {"op": "replace", "path": "/rolloutStatus", "value": {"id": "<status-uuid>"}}
])

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