scim2-client 0.1.11__tar.gz → 0.2.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scim2-client
3
- Version: 0.1.11
3
+ Version: 0.2.0
4
4
  Summary: Pythonically build SCIM requests and parse SCIM responses
5
5
  License: MIT
6
6
  Keywords: scim,scim2,provisioning,httpx,api
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "scim2-client"
7
- version = "0.1.11"
7
+ version = "0.2.0"
8
8
  description = "Pythonically build SCIM requests and parse SCIM responses"
9
9
  authors = ["Yaal Coop <contact@yaal.coop>"]
10
10
  license = "MIT"
@@ -163,7 +163,7 @@ class SCIMClient:
163
163
  expected_status_codes: List[int],
164
164
  expected_types: Optional[Type] = None,
165
165
  check_response_payload: bool = True,
166
- raise_scim_errors: bool = False,
166
+ raise_scim_errors: bool = True,
167
167
  scim_ctx: Optional[Context] = None,
168
168
  ):
169
169
  if expected_status_codes and response.status_code not in expected_status_codes:
@@ -240,8 +240,8 @@ class SCIMClient:
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,
244
- raise_scim_errors: bool = False,
243
+ expected_status_codes: Optional[List[int]] = CREATION_RESPONSE_STATUS_CODES,
244
+ raise_scim_errors: bool = True,
245
245
  **kwargs,
246
246
  ) -> Union[AnyResource, Error, Dict]:
247
247
  """Perform a POST request to create, as defined in :rfc:`RFC7644 §3.3
@@ -253,7 +253,8 @@ class SCIMClient:
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 @@ class SCIMClient:
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,8 +333,8 @@ class SCIMClient:
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,
338
- raise_scim_errors: bool = False,
336
+ expected_status_codes: Optional[List[int]] = QUERY_RESPONSE_STATUS_CODES,
337
+ raise_scim_errors: bool = True,
339
338
  **kwargs,
340
339
  ) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
341
340
  """Perform a GET request to read resources, as defined in :rfc:`RFC7644
@@ -351,7 +350,8 @@ class SCIMClient:
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 @@ class SCIMClient:
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,8 +459,8 @@ class SCIMClient:
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,
465
- raise_scim_errors: bool = False,
462
+ expected_status_codes: Optional[List[int]] = SEARCH_RESPONSE_STATUS_CODES,
463
+ raise_scim_errors: bool = True,
466
464
  **kwargs,
467
465
  ) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
468
466
  """Perform a POST search request to read all available resources, as
@@ -475,7 +473,8 @@ class SCIMClient:
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 @@ class SCIMClient:
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,8 +539,8 @@ class SCIMClient:
542
539
  resource_type: Type,
543
540
  id: str,
544
541
  check_response_payload: bool = True,
545
- check_status_code: bool = True,
546
- raise_scim_errors: bool = False,
542
+ expected_status_codes: Optional[List[int]] = DELETION_RESPONSE_STATUS_CODES,
543
+ raise_scim_errors: bool = True,
547
544
  **kwargs,
548
545
  ) -> Optional[Union[Error, Dict]]:
549
546
  """Perform a DELETE request to create, as defined in :rfc:`RFC7644 §3.6
@@ -553,7 +550,8 @@ class SCIMClient:
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 @@ class SCIMClient:
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,8 +596,8 @@ class SCIMClient:
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,
604
- raise_scim_errors: bool = False,
599
+ expected_status_codes: Optional[List[int]] = REPLACEMENT_RESPONSE_STATUS_CODES,
600
+ raise_scim_errors: bool = True,
605
601
  **kwargs,
606
602
  ) -> Union[AnyResource, Error, Dict]:
607
603
  """Perform a PUT request to replace a resource, as defined in
@@ -613,7 +609,8 @@ class SCIMClient:
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 @@ class SCIMClient:
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,
File without changes