Skip to content

Commit 3bc7ad1

Browse files
committed
Update version to 3.5.8 and add support for optional org_identifier and project_identifier in Harness microclients. Modify API request URLs to conditionally include these parameters,
1 parent c46ee45 commit 3bc7ad1

25 files changed

Lines changed: 2126 additions & 350 deletions

CHANGES.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,16 @@ CHANGELOG
33

44
This file tracks the version history and changes made to the Split/Harness FME Python API Client library.
55

6+
3.5.8 (December 4, 2025)
7+
-------------------------
8+
Features:
9+
- Added optional org_identifier and project_identifier support for Harness microclients
10+
- These parameters can be set at client initialization or passed to individual method calls
11+
- Parameters are only included in API request URLs when they are set (not None)
12+
- When not provided, they are completely omitted from URLs rather than being passed as empty strings
13+
- Applies to all Harness microclients: harness_project, harness_user, harness_group,
14+
harness_apikey, service_account, token, role, resource_group, and role_assignment
15+
616
3.5.7 (November 26, 2025)
717
-------------------------
818
Bug Fixes:

README.md

Lines changed: 55 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,15 @@ client = get_client({
5858
'harness_token': 'YOUR_HARNESS_TOKEN', # Used for both Harness and Split endpoints
5959
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID'
6060
})
61+
62+
# Option 3: Include optional org_identifier and project_identifier
63+
client = get_client({
64+
'harness_mode': True,
65+
'harness_token': 'YOUR_HARNESS_TOKEN',
66+
'account_identifier': 'YOUR_HARNESS_ACCOUNT_ID',
67+
'org_identifier': 'YOUR_ORG_ID', # Optional: organization identifier
68+
'project_identifier': 'YOUR_PROJECT_ID' # Optional: project identifier
69+
})
6170
```
6271

6372
### Working with Split Resources in Harness Mode
@@ -97,15 +106,30 @@ Basic example:
97106
# Account identifier is required for all Harness operations
98107
account_id = 'YOUR_ACCOUNT_IDENTIFIER'
99108

100-
# List all tokens
109+
# List all tokens (org_identifier and project_identifier are optional)
101110
tokens = client.token.list(account_id)
102111
for token in tokens:
103112
print(f"Token: {token.name}, ID: {token.id}")
104113

105-
# List service accounts
106-
service_accounts = client.service_account.list(account_id)
114+
# List service accounts with org and project identifiers
115+
org_id = 'YOUR_ORG_IDENTIFIER'
116+
project_id = 'YOUR_PROJECT_IDENTIFIER'
117+
service_accounts = client.service_account.list(account_id, org_identifier=org_id, project_identifier=project_id)
107118
for sa in service_accounts:
108119
print(f"Service Account: {sa.name}, ID: {sa.id}")
120+
121+
# If org_identifier and project_identifier are set at client initialization, you can omit them
122+
client = get_client({
123+
'harness_mode': True,
124+
'harness_token': 'YOUR_HARNESS_TOKEN',
125+
'account_identifier': account_id,
126+
'org_identifier': org_id,
127+
'project_identifier': project_id
128+
})
129+
130+
# Now you can call methods without specifying identifiers
131+
service_accounts = client.service_account.list() # Uses default identifiers
132+
projects = client.harness_project.list() # Uses default identifiers
109133
```
110134

111135
For most creation, update, and delete endpoints for harness specific resources, you will need to pass through the JSON body directly.
@@ -133,21 +157,43 @@ client.harness_user.add_user_to_groups(user.id, [group.id], account_id)
133157

134158
For detailed examples and API specifications for each resource, please refer to the [Harness API documentation](https://apidocs.harness.io/).
135159

136-
### Setting Default Account Identifier
160+
### Setting Default Identifiers
137161

138-
To avoid specifying the account identifier with every request:
162+
To avoid specifying identifiers with every request, you can set default values when creating the client:
139163

140164
```python
141-
# Set default account identifier when creating the client
165+
# Set default identifiers when creating the client
142166
client = get_client({
143167
'harness_mode': True,
144168
'harness_token': 'YOUR_HARNESS_TOKEN',
145-
'account_identifier': 'YOUR_ACCOUNT_IDENTIFIER'
169+
'account_identifier': 'YOUR_ACCOUNT_IDENTIFIER', # Required
170+
'org_identifier': 'YOUR_ORG_IDENTIFIER', # Optional
171+
'project_identifier': 'YOUR_PROJECT_IDENTIFIER' # Optional
146172
})
147173

148-
# Now you can make calls without specifying account_identifier in each request
174+
# Now you can make calls without specifying identifiers in each request
149175
tokens = client.token.list() # account_identifier is automatically included
150-
projects = client.harness_project.list() # account_identifier is automatically included
176+
projects = client.harness_project.list() # account_identifier and org_identifier are automatically included (project_identifier is not used for projects endpoint)
177+
```
178+
179+
**Note on Optional Identifiers:**
180+
- `account_identifier` is **required** for all Harness operations
181+
- `org_identifier` and `project_identifier` are **optional** and will be omitted from API requests if not provided
182+
- If `org_identifier` or `project_identifier` are not set, they will not appear in the URL at all (not even as empty parameters)
183+
- **Important:** The `harness_project` microclient does **not** support `project_identifier` as a query parameter. The projects endpoint only uses `org_identifier` (and `account_identifier`). Other microclients (service_account, token, role, etc.) do support `project_identifier`.
184+
- You can override default identifiers by passing them as parameters to individual method calls:
185+
186+
```python
187+
# Override default identifiers for a specific request
188+
# Note: project_identifier is not used for harness_project endpoints
189+
projects = client.harness_project.list(
190+
account_identifier='DIFFERENT_ACCOUNT_ID',
191+
org_identifier='DIFFERENT_ORG_ID'
192+
)
193+
194+
# Use default identifiers but override only org_identifier
195+
# Note: project_identifier is not used for harness_project endpoints
196+
projects = client.harness_project.list(org_identifier='DIFFERENT_ORG_ID')
151197
```
152198

153199
## Quick Setup

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "splitapiclient"
7-
version = "3.5.7"
7+
version = "3.5.8"
88
license = "Apache-2.0"
99
description = "This Python Library provides full support for Split REST Admin API, allow creating, deleting and editing Environments, Splits, Split Definitions, Segments, Segment Keys, Users, Groups, API Keys, Change Requests, Attributes and Identities"
1010
classifiers = [

splitapiclient/main/harness_apiclient.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ def __init__(self, config):
5353
- 'base_url_v3': Base url where the Split API v3 is hosted (optional, defaults to Split URL)
5454
- 'harness_base_url': Base url where the Harness API is hosted (optional, defaults to Harness URL)
5555
- 'account_identifier': Harness account identifier to use for all Harness operations (optional)
56+
- 'org_identifier': Harness organization identifier to use for all Harness operations (optional)
57+
- 'project_identifier': Harness project identifier to use for all Harness operations (optional)
5658
'''
5759
# Set up Split API base URLs for existing endpoints
5860
if 'base_url' in config:
@@ -87,8 +89,10 @@ def __init__(self, config):
8789
split_auth_token = self._apikey if self._apikey else self._harness_token
8890
harness_auth_token = self._harness_token if self._harness_token else self._apikey
8991

90-
# Store the account identifier
92+
# Store the account identifier, org identifier, and project identifier
9193
self._account_identifier = config.get('account_identifier')
94+
self._org_identifier = config.get('org_identifier')
95+
self._project_identifier = config.get('project_identifier')
9296

9397
# Create HTTP clients for Split endpoints
9498
split_http_client = HarnessHttpClient(self._base_url, split_auth_token)
@@ -114,15 +118,15 @@ def __init__(self, config):
114118
self._flag_set_client = FlagSetMicroClient(split_http_clientv3)
115119

116120
# Harness-specific microclients using Harness endpoints
117-
self._token_client = TokenMicroClient(harness_http_client, self._account_identifier)
118-
self._harness_apikey_client = HarnessApiKeyMicroClient(harness_http_client, self._account_identifier)
119-
self._service_account_client = ServiceAccountMicroClient(harness_http_client, self._account_identifier)
120-
self._harness_user_client = HarnessUserMicroClient(harness_http_client, self._account_identifier)
121-
self._harness_group_client = HarnessGroupMicroClient(harness_http_client, self._account_identifier)
122-
self._role_client = RoleMicroClient(harness_http_client, self._account_identifier)
123-
self._resource_group_client = ResourceGroupMicroClient(harness_http_client, self._account_identifier)
124-
self._role_assignment_client = RoleAssignmentMicroClient(harness_http_client, self._account_identifier)
125-
self._harness_project_client = HarnessProjectMicroClient(harness_http_client, self._account_identifier)
121+
self._token_client = TokenMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
122+
self._harness_apikey_client = HarnessApiKeyMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
123+
self._service_account_client = ServiceAccountMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
124+
self._harness_user_client = HarnessUserMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
125+
self._harness_group_client = HarnessGroupMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
126+
self._role_client = RoleMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
127+
self._resource_group_client = ResourceGroupMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
128+
self._role_assignment_client = RoleAssignmentMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
129+
self._harness_project_client = HarnessProjectMicroClient(harness_http_client, self._account_identifier, self._org_identifier, self._project_identifier)
126130

127131
@property
128132
def traffic_types(self):

0 commit comments

Comments
 (0)