@@ -3345,6 +3345,19 @@ def jql(
3345
3345
:param validate_query: OPTIONAL: Whether to validate the JQL query
3346
3346
:return:
3347
3347
"""
3348
+ if self .cloud :
3349
+ if start == 0 :
3350
+ return self .enhanced_jql (
3351
+ jql = jql ,
3352
+ fields = fields ,
3353
+ limit = limit ,
3354
+ expand = expand ,
3355
+ )
3356
+ else :
3357
+ raise ValueError (
3358
+ "The `jql` method is deprecated in Jira Cloud. Use `enhanced_jql` method instead."
3359
+ )
3360
+
3348
3361
params = {}
3349
3362
if start is not None :
3350
3363
params ["startAt" ] = int (start )
@@ -3363,6 +3376,64 @@ def jql(
3363
3376
url = self .resource_url ("search" )
3364
3377
return self .get (url , params = params )
3365
3378
3379
+ def enhanced_jql (
3380
+ self ,
3381
+ jql ,
3382
+ fields = "*all" ,
3383
+ nextPageToken = None ,
3384
+ limit = None ,
3385
+ expand = None ,
3386
+ ):
3387
+ """
3388
+ Get issues from jql search result with all related fields
3389
+ :param jql:
3390
+ :param fields: list of fields, for example: ['priority', 'summary', 'customfield_10007']
3391
+ :param nextPageToken (Optional[str]): Token for paginated results. Default: None.
3392
+ :param limit: OPTIONAL: The limit of the number of issues to return, this may be restricted by
3393
+ fixed system limits. Default by built-in method: 50
3394
+ :param expand: OPTIONAL: expand the search result
3395
+ :return:
3396
+ """
3397
+
3398
+ if not self .cloud :
3399
+ raise ValueError ("``enhanced_jql`` method is only available for Jira Cloud platform" )
3400
+
3401
+ params = {}
3402
+ if nextPageToken is not None :
3403
+ params ["nextPageToken" ] = str (nextPageToken )
3404
+ if limit is not None :
3405
+ params ["maxResults" ] = int (limit )
3406
+ if fields is not None :
3407
+ if isinstance (fields , (list , tuple , set )):
3408
+ fields = "," .join (fields )
3409
+ params ["fields" ] = fields
3410
+ if jql is not None :
3411
+ params ["jql" ] = jql
3412
+ if expand is not None :
3413
+ params ["expand" ] = expand
3414
+
3415
+ url = self .resource_url ("search/jql" )
3416
+ return self .get (url , params = params )
3417
+
3418
+ def approximate_issue_count (
3419
+ self ,
3420
+ jql ,
3421
+ ):
3422
+ """
3423
+ Get an approximate count of issues matching a JQL search string.
3424
+
3425
+ :param jql: The JQL search string.
3426
+ :return: The issue count.
3427
+ """
3428
+
3429
+ if not self .cloud :
3430
+ raise ValueError ("``approximate_issue_count`` method is only available for Jira Cloud platform" )
3431
+
3432
+ data = {"jql" : jql }
3433
+
3434
+ url = self .resource_url ("search/approximate-count" )
3435
+ return self .post (url , data )
3436
+
3366
3437
def jql_get_list_of_tickets (
3367
3438
self ,
3368
3439
jql ,
@@ -3383,6 +3454,19 @@ def jql_get_list_of_tickets(
3383
3454
:param validate_query: Whether to validate the JQL query
3384
3455
:return:
3385
3456
"""
3457
+ if self .cloud :
3458
+ if start == 0 :
3459
+ return self .enhanced_jql_get_list_of_tickets (
3460
+ jql = jql ,
3461
+ fields = fields ,
3462
+ limit = limit ,
3463
+ expand = expand ,
3464
+ )
3465
+ else :
3466
+ raise ValueError (
3467
+ "The `jql_get_list_of_tickets` method is deprecated in Jira Cloud. Use `enhanced_jql_get_list_of_tickets` method instead."
3468
+ )
3469
+
3386
3470
params = {}
3387
3471
if limit is not None :
3388
3472
params ["maxResults" ] = int (limit )
@@ -3404,7 +3488,7 @@ def jql_get_list_of_tickets(
3404
3488
response = self .get (url , params = params )
3405
3489
if not response :
3406
3490
break
3407
-
3491
+
3408
3492
issues = response ["issues" ]
3409
3493
results .extend (issues )
3410
3494
total = int (response ["total" ])
@@ -3413,7 +3497,61 @@ def jql_get_list_of_tickets(
3413
3497
if limit is not None or total <= len (response ["issues" ]) + start :
3414
3498
break
3415
3499
start += len (issues )
3500
+ return results
3501
+
3502
+ def enhanced_jql_get_list_of_tickets (
3503
+ self ,
3504
+ jql ,
3505
+ fields = "*all" ,
3506
+ limit = None ,
3507
+ expand = None ,
3508
+ ):
3509
+ """
3510
+ Get issues from JQL search result with all related fields using nextPageToken pagination.
3511
+
3512
+ Applicable only for Jira Cloud.
3513
+
3514
+ :param jql: The JQL search string.
3515
+ :param fields: List of fields, for example: ['priority', 'summary', 'customfield_10007']
3516
+ :param limit: OPTIONAL: The limit of the number of issues to return, this may be restricted by
3517
+ fixed system limits. Default by built-in method: 50
3518
+ :param expand: OPTIONAL: Expand the search result.
3519
+ :return: List of issues.
3520
+ """
3521
+
3522
+ if not self .cloud :
3523
+ raise ValueError ("``enhanced_jql_get_list_of_tickets`` is only available for Jira Cloud." )
3524
+
3525
+ params = {}
3526
+ if limit is not None :
3527
+ params ["maxResults" ] = int (limit )
3528
+ if fields is not None :
3529
+ if isinstance (fields , (list , tuple , set )):
3530
+ fields = "," .join (fields )
3531
+ params ["fields" ] = fields
3532
+ if jql is not None :
3533
+ params ["jql" ] = jql
3534
+ if expand is not None :
3535
+ params ["expand" ] = expand
3416
3536
3537
+ url = self .resource_url ("search/jql" )
3538
+ results = []
3539
+ nextPageToken = None
3540
+
3541
+ while True :
3542
+ if nextPageToken is not None :
3543
+ params ["nextPageToken" ] = nextPageToken
3544
+
3545
+ response = self .get (url , params = params )
3546
+ if not response :
3547
+ break
3548
+
3549
+ issues = response ["issues" ]
3550
+ results .extend (issues )
3551
+
3552
+ nextPageToken = response .get ("nextPageToken" )
3553
+ if not nextPageToken or (limit is not None and len (results ) >= limit ):
3554
+ break
3417
3555
return results
3418
3556
3419
3557
def csv (self , jql , limit = 1000 , all_fields = True , start = None , delimiter = None ):
0 commit comments