@@ -240,7 +240,7 @@ def create(
240
240
resource : Union [AnyResource , Dict ],
241
241
check_request_payload : bool = True ,
242
242
check_response_payload : bool = True ,
243
- check_status_code : bool = True ,
243
+ expected_status_codes : Optional [ List [ int ]] = CREATION_RESPONSE_STATUS_CODES ,
244
244
raise_scim_errors : bool = False ,
245
245
** kwargs ,
246
246
) -> Union [AnyResource , Error , Dict ]:
@@ -253,7 +253,8 @@ def create(
253
253
:code:`resource` is expected to be a dict that will be passed as-is in the request.
254
254
:param check_response_payload: Whether to validate that the response payload is valid.
255
255
If set, the raw payload will be returned.
256
- :param check_status_code: Whether to validate that the response status code is valid.
256
+ :param expected_status_codes: The list of expected status codes form the response.
257
+ If :data:`None` any status code is accepted.
257
258
:param raise_scim_errors: If :data:`True` and the server returned an
258
259
:class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
259
260
exception will be raised. If :data:`False` the error object is returned.
@@ -318,9 +319,7 @@ def create(
318
319
319
320
return self .check_response (
320
321
response = response ,
321
- expected_status_codes = (
322
- self .CREATION_RESPONSE_STATUS_CODES if check_status_code else None
323
- ),
322
+ expected_status_codes = expected_status_codes ,
324
323
expected_types = ([resource .__class__ ] if check_request_payload else None ),
325
324
check_response_payload = check_response_payload ,
326
325
raise_scim_errors = raise_scim_errors ,
@@ -334,7 +333,7 @@ def query(
334
333
search_request : Optional [Union [SearchRequest , Dict ]] = None ,
335
334
check_request_payload : bool = True ,
336
335
check_response_payload : bool = True ,
337
- check_status_code : bool = True ,
336
+ expected_status_codes : Optional [ List [ int ]] = QUERY_RESPONSE_STATUS_CODES ,
338
337
raise_scim_errors : bool = False ,
339
338
** kwargs ,
340
339
) -> Union [AnyResource , ListResponse [AnyResource ], Error , Dict ]:
@@ -351,7 +350,8 @@ def query(
351
350
:code:`search_request` is expected to be a dict that will be passed as-is in the request.
352
351
:param check_response_payload: Whether to validate that the response payload is valid.
353
352
If set, the raw payload will be returned.
354
- :param check_status_code: Whether to validate that the response status code is valid.
353
+ :param expected_status_codes: The list of expected status codes form the response.
354
+ If :data:`None` any status code is accepted.
355
355
:param raise_scim_errors: If :data:`True` and the server returned an
356
356
:class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
357
357
exception will be raised. If :data:`False` the error object is returned.
@@ -447,9 +447,7 @@ def query(
447
447
448
448
return self .check_response (
449
449
response = response ,
450
- expected_status_codes = (
451
- self .QUERY_RESPONSE_STATUS_CODES if check_status_code else None
452
- ),
450
+ expected_status_codes = expected_status_codes ,
453
451
expected_types = expected_types ,
454
452
check_response_payload = check_response_payload ,
455
453
raise_scim_errors = raise_scim_errors ,
@@ -461,7 +459,7 @@ def search(
461
459
search_request : Optional [SearchRequest ] = None ,
462
460
check_request_payload : bool = True ,
463
461
check_response_payload : bool = True ,
464
- check_status_code : bool = True ,
462
+ expected_status_codes : Optional [ List [ int ]] = SEARCH_RESPONSE_STATUS_CODES ,
465
463
raise_scim_errors : bool = False ,
466
464
** kwargs ,
467
465
) -> Union [AnyResource , ListResponse [AnyResource ], Error , Dict ]:
@@ -475,7 +473,8 @@ def search(
475
473
:code:`search_request` is expected to be a dict that will be passed as-is in the request.
476
474
:param check_response_payload: Whether to validate that the response payload is valid.
477
475
If set, the raw payload will be returned.
478
- :param check_status_code: Whether to validate that the response status code is valid.
476
+ :param expected_status_codes: The list of expected status codes form the response.
477
+ If :data:`None` any status code is accepted.
479
478
:param raise_scim_errors: If :data:`True` and the server returned an
480
479
:class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
481
480
exception will be raised. If :data:`False` the error object is returned.
@@ -528,9 +527,7 @@ def search(
528
527
529
528
return self .check_response (
530
529
response = response ,
531
- expected_status_codes = (
532
- self .SEARCH_RESPONSE_STATUS_CODES if check_status_code else None
533
- ),
530
+ expected_status_codes = expected_status_codes ,
534
531
expected_types = [ListResponse [Union [self .resource_types ]]],
535
532
check_response_payload = check_response_payload ,
536
533
raise_scim_errors = raise_scim_errors ,
@@ -542,7 +539,7 @@ def delete(
542
539
resource_type : Type ,
543
540
id : str ,
544
541
check_response_payload : bool = True ,
545
- check_status_code : bool = True ,
542
+ expected_status_codes : Optional [ List [ int ]] = DELETION_RESPONSE_STATUS_CODES ,
546
543
raise_scim_errors : bool = False ,
547
544
** kwargs ,
548
545
) -> Optional [Union [Error , Dict ]]:
@@ -553,7 +550,8 @@ def delete(
553
550
:param id: The type id the resource to delete.
554
551
:param check_response_payload: Whether to validate that the response payload is valid.
555
552
If set, the raw payload will be returned.
556
- :param check_status_code: Whether to validate that the response status code is valid.
553
+ :param expected_status_codes: The list of expected status codes form the response.
554
+ If :data:`None` any status code is accepted.
557
555
:param raise_scim_errors: If :data:`True` and the server returned an
558
556
:class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
559
557
exception will be raised. If :data:`False` the error object is returned.
@@ -588,9 +586,7 @@ def delete(
588
586
589
587
return self .check_response (
590
588
response = response ,
591
- expected_status_codes = (
592
- self .DELETION_RESPONSE_STATUS_CODES if check_status_code else None
593
- ),
589
+ expected_status_codes = expected_status_codes ,
594
590
check_response_payload = check_response_payload ,
595
591
raise_scim_errors = raise_scim_errors ,
596
592
)
@@ -600,7 +596,7 @@ def replace(
600
596
resource : Union [AnyResource , Dict ],
601
597
check_request_payload : bool = True ,
602
598
check_response_payload : bool = True ,
603
- check_status_code : bool = True ,
599
+ expected_status_codes : Optional [ List [ int ]] = REPLACEMENT_RESPONSE_STATUS_CODES ,
604
600
raise_scim_errors : bool = False ,
605
601
** kwargs ,
606
602
) -> Union [AnyResource , Error , Dict ]:
@@ -613,7 +609,8 @@ def replace(
613
609
:code:`resource` is expected to be a dict that will be passed as-is in the request.
614
610
:param check_response_payload: Whether to validate that the response payload is valid.
615
611
If set, the raw payload will be returned.
616
- :param check_status_code: Whether to validate that the response status code is valid.
612
+ :param expected_status_codes: The list of expected status codes form the response.
613
+ If :data:`None` any status code is accepted.
617
614
:param raise_scim_errors: If :data:`True` and the server returned an
618
615
:class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
619
616
exception will be raised. If :data:`False` the error object is returned.
@@ -687,9 +684,7 @@ def replace(
687
684
688
685
return self .check_response (
689
686
response = response ,
690
- expected_status_codes = (
691
- self .REPLACEMENT_RESPONSE_STATUS_CODES if check_status_code else None
692
- ),
687
+ expected_status_codes = expected_status_codes ,
693
688
expected_types = ([resource .__class__ ] if check_request_payload else None ),
694
689
check_response_payload = check_response_payload ,
695
690
raise_scim_errors = raise_scim_errors ,
0 commit comments