python-jira-plus 1.0.6__tar.gz → 1.0.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python_jira_plus-1.0.6/python_jira_plus.egg-info → python_jira_plus-1.0.7}/PKG-INFO +1 -1
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus/jira_plus.py +36 -9
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7/python_jira_plus.egg-info}/PKG-INFO +1 -1
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/setup.py +1 -1
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/LICENSE +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/MANIFEST.in +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/README.md +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/pyproject.toml +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus/__init__.py +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus/describe_allowed_value.py +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus.egg-info/SOURCES.txt +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus.egg-info/dependency_links.txt +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus.egg-info/requires.txt +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus.egg-info/top_level.txt +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/requirements.txt +0 -0
- {python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/setup.cfg +0 -0
|
@@ -197,13 +197,16 @@ class JiraPlus:
|
|
|
197
197
|
"""
|
|
198
198
|
Returns the allowed values for a specific field in a project + issue type context.
|
|
199
199
|
"""
|
|
200
|
-
|
|
200
|
+
fields_metadata = self.get_project_fields_metadata(
|
|
201
|
+
project_key=project_key,
|
|
202
|
+
issue_type=issue_type
|
|
203
|
+
)
|
|
201
204
|
|
|
202
205
|
# Try to find by ID or fallback to case-insensitive name
|
|
203
|
-
field =
|
|
206
|
+
field = fields_metadata.get(field_id_or_name)
|
|
204
207
|
if not field:
|
|
205
208
|
# Try matching by name (case-insensitive)
|
|
206
|
-
for fid, fmeta in
|
|
209
|
+
for fid, fmeta in fields_metadata.items():
|
|
207
210
|
if fmeta['name'].lower() == field_id_or_name.lower():
|
|
208
211
|
field = fmeta
|
|
209
212
|
break
|
|
@@ -225,28 +228,53 @@ class JiraPlus:
|
|
|
225
228
|
allowed_values = allowed_names | allowed_keys
|
|
226
229
|
return describe_allowed_value(value, allowed_values=allowed_values)
|
|
227
230
|
|
|
231
|
+
def get_server_version(self):
|
|
232
|
+
return tuple(self.jira_client.server_info()['versionNumbers'])
|
|
233
|
+
|
|
234
|
+
def check_server_createmeta_compatibility(self) -> bool:
|
|
235
|
+
server_version = self.get_server_version()
|
|
236
|
+
if self.server_type == ServerType.ON_PREMISE and server_version < (8, 0, 0):
|
|
237
|
+
self.logger.warning(
|
|
238
|
+
f"JIRA server version {server_version} is below the minimum required version (8.0.0). "
|
|
239
|
+
"Some features may not work as expected."
|
|
240
|
+
)
|
|
241
|
+
return False
|
|
242
|
+
return True
|
|
243
|
+
|
|
244
|
+
def get_project_fields_metadata(self, project_key: str, issue_type: str) -> dict:
|
|
245
|
+
if self.check_server_createmeta_compatibility():
|
|
246
|
+
meta, issue_meta = self._fetch_metadata(project_key=project_key, issue_type=issue_type)
|
|
247
|
+
return issue_meta['fields']
|
|
248
|
+
else:
|
|
249
|
+
_project_issue_types = self.jira_client.project_issue_types(project_key)
|
|
250
|
+
_issue_types = {t.name: t for t in _project_issue_types}
|
|
251
|
+
field_list = self.jira_client.project_issue_fields(project_key, _issue_types[issue_type].id)
|
|
252
|
+
return {f.fieldId: f.raw for f in field_list}
|
|
253
|
+
|
|
228
254
|
def validate_fields(
|
|
229
255
|
self,
|
|
230
256
|
project_key: str,
|
|
231
257
|
issue_type: str,
|
|
232
258
|
fields: Optional[dict] = None
|
|
233
259
|
) -> None:
|
|
234
|
-
|
|
235
|
-
|
|
260
|
+
fields_metadata = self.get_project_fields_metadata(
|
|
261
|
+
project_key=project_key,
|
|
262
|
+
issue_type=issue_type
|
|
263
|
+
)
|
|
236
264
|
for custom_field, value in fields.items():
|
|
237
|
-
if custom_field not in
|
|
265
|
+
if custom_field not in fields_metadata:
|
|
238
266
|
raise ValueError(
|
|
239
267
|
f'Invalid field(s) for project "{project_key}", issue type "{issue_type}": "{custom_field}"'
|
|
240
268
|
)
|
|
241
269
|
|
|
242
|
-
if allowed_value :=
|
|
270
|
+
if allowed_value := fields_metadata[custom_field].get('allowedValues'):
|
|
243
271
|
if not self._is_value_allowed(value=value, allowed_values=allowed_value):
|
|
244
272
|
raise ValueError(
|
|
245
273
|
f"Invalid value '{value}' for field '{custom_field}' in project '{project_key}' with issue type '{issue_type}'."
|
|
246
274
|
f"The allowed values are: {json.dumps(allowed_value, indent=4, sort_keys=True)}"
|
|
247
275
|
)
|
|
248
276
|
|
|
249
|
-
field_type =
|
|
277
|
+
field_type = fields_metadata[custom_field]['schema']['type']
|
|
250
278
|
if field_type == 'string' and not isinstance(value, str):
|
|
251
279
|
raise ValueError(f"Field '{custom_field}' must be a string")
|
|
252
280
|
elif field_type == 'number' and not isinstance(value, (int, float)):
|
|
@@ -260,7 +288,6 @@ class JiraPlus:
|
|
|
260
288
|
elif field_type == 'issuetype' and not isinstance(value, dict):
|
|
261
289
|
raise ValueError(f"Field '{custom_field}' must be an issue type")
|
|
262
290
|
# Add more field type checks as needed
|
|
263
|
-
return issue_meta['fields'].keys()
|
|
264
291
|
|
|
265
292
|
def create_issue(
|
|
266
293
|
self,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus/describe_allowed_value.py
RENAMED
|
File without changes
|
|
File without changes
|
{python_jira_plus-1.0.6 → python_jira_plus-1.0.7}/python_jira_plus.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|