scim2-client 0.1.10__py3-none-any.whl → 0.2.0__py3-none-any.whl

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.
scim2_client/client.py CHANGED
@@ -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:
@@ -176,7 +176,10 @@ class SCIMClient:
176
176
  # https://datatracker.ietf.org/doc/html/rfc7644.html#section-8.1
177
177
 
178
178
  expected_response_content_types = ("application/scim+json", "application/json")
179
- if response.headers.get("content-type") not in expected_response_content_types:
179
+ if (
180
+ response.headers.get("content-type").split(";").pop(0)
181
+ not in expected_response_content_types
182
+ ):
180
183
  raise UnexpectedContentType(source=response)
181
184
 
182
185
  # In addition to returning an HTTP response code, implementers MUST return
@@ -237,8 +240,8 @@ class SCIMClient:
237
240
  resource: Union[AnyResource, Dict],
238
241
  check_request_payload: bool = True,
239
242
  check_response_payload: bool = True,
240
- check_status_code: bool = True,
241
- raise_scim_errors: bool = False,
243
+ expected_status_codes: Optional[List[int]] = CREATION_RESPONSE_STATUS_CODES,
244
+ raise_scim_errors: bool = True,
242
245
  **kwargs,
243
246
  ) -> Union[AnyResource, Error, Dict]:
244
247
  """Perform a POST request to create, as defined in :rfc:`RFC7644 §3.3
@@ -250,7 +253,8 @@ class SCIMClient:
250
253
  :code:`resource` is expected to be a dict that will be passed as-is in the request.
251
254
  :param check_response_payload: Whether to validate that the response payload is valid.
252
255
  If set, the raw payload will be returned.
253
- :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.
254
258
  :param raise_scim_errors: If :data:`True` and the server returned an
255
259
  :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
256
260
  exception will be raised. If :data:`False` the error object is returned.
@@ -315,9 +319,7 @@ class SCIMClient:
315
319
 
316
320
  return self.check_response(
317
321
  response=response,
318
- expected_status_codes=(
319
- self.CREATION_RESPONSE_STATUS_CODES if check_status_code else None
320
- ),
322
+ expected_status_codes=expected_status_codes,
321
323
  expected_types=([resource.__class__] if check_request_payload else None),
322
324
  check_response_payload=check_response_payload,
323
325
  raise_scim_errors=raise_scim_errors,
@@ -331,8 +333,8 @@ class SCIMClient:
331
333
  search_request: Optional[Union[SearchRequest, Dict]] = None,
332
334
  check_request_payload: bool = True,
333
335
  check_response_payload: bool = True,
334
- check_status_code: bool = True,
335
- raise_scim_errors: bool = False,
336
+ expected_status_codes: Optional[List[int]] = QUERY_RESPONSE_STATUS_CODES,
337
+ raise_scim_errors: bool = True,
336
338
  **kwargs,
337
339
  ) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
338
340
  """Perform a GET request to read resources, as defined in :rfc:`RFC7644
@@ -348,7 +350,8 @@ class SCIMClient:
348
350
  :code:`search_request` is expected to be a dict that will be passed as-is in the request.
349
351
  :param check_response_payload: Whether to validate that the response payload is valid.
350
352
  If set, the raw payload will be returned.
351
- :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.
352
355
  :param raise_scim_errors: If :data:`True` and the server returned an
353
356
  :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
354
357
  exception will be raised. If :data:`False` the error object is returned.
@@ -444,9 +447,7 @@ class SCIMClient:
444
447
 
445
448
  return self.check_response(
446
449
  response=response,
447
- expected_status_codes=(
448
- self.QUERY_RESPONSE_STATUS_CODES if check_status_code else None
449
- ),
450
+ expected_status_codes=expected_status_codes,
450
451
  expected_types=expected_types,
451
452
  check_response_payload=check_response_payload,
452
453
  raise_scim_errors=raise_scim_errors,
@@ -458,8 +459,8 @@ class SCIMClient:
458
459
  search_request: Optional[SearchRequest] = None,
459
460
  check_request_payload: bool = True,
460
461
  check_response_payload: bool = True,
461
- check_status_code: bool = True,
462
- raise_scim_errors: bool = False,
462
+ expected_status_codes: Optional[List[int]] = SEARCH_RESPONSE_STATUS_CODES,
463
+ raise_scim_errors: bool = True,
463
464
  **kwargs,
464
465
  ) -> Union[AnyResource, ListResponse[AnyResource], Error, Dict]:
465
466
  """Perform a POST search request to read all available resources, as
@@ -472,7 +473,8 @@ class SCIMClient:
472
473
  :code:`search_request` is expected to be a dict that will be passed as-is in the request.
473
474
  :param check_response_payload: Whether to validate that the response payload is valid.
474
475
  If set, the raw payload will be returned.
475
- :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.
476
478
  :param raise_scim_errors: If :data:`True` and the server returned an
477
479
  :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
478
480
  exception will be raised. If :data:`False` the error object is returned.
@@ -525,9 +527,7 @@ class SCIMClient:
525
527
 
526
528
  return self.check_response(
527
529
  response=response,
528
- expected_status_codes=(
529
- self.SEARCH_RESPONSE_STATUS_CODES if check_status_code else None
530
- ),
530
+ expected_status_codes=expected_status_codes,
531
531
  expected_types=[ListResponse[Union[self.resource_types]]],
532
532
  check_response_payload=check_response_payload,
533
533
  raise_scim_errors=raise_scim_errors,
@@ -539,8 +539,8 @@ class SCIMClient:
539
539
  resource_type: Type,
540
540
  id: str,
541
541
  check_response_payload: bool = True,
542
- check_status_code: bool = True,
543
- raise_scim_errors: bool = False,
542
+ expected_status_codes: Optional[List[int]] = DELETION_RESPONSE_STATUS_CODES,
543
+ raise_scim_errors: bool = True,
544
544
  **kwargs,
545
545
  ) -> Optional[Union[Error, Dict]]:
546
546
  """Perform a DELETE request to create, as defined in :rfc:`RFC7644 §3.6
@@ -550,7 +550,8 @@ class SCIMClient:
550
550
  :param id: The type id the resource to delete.
551
551
  :param check_response_payload: Whether to validate that the response payload is valid.
552
552
  If set, the raw payload will be returned.
553
- :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.
554
555
  :param raise_scim_errors: If :data:`True` and the server returned an
555
556
  :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
556
557
  exception will be raised. If :data:`False` the error object is returned.
@@ -585,9 +586,7 @@ class SCIMClient:
585
586
 
586
587
  return self.check_response(
587
588
  response=response,
588
- expected_status_codes=(
589
- self.DELETION_RESPONSE_STATUS_CODES if check_status_code else None
590
- ),
589
+ expected_status_codes=expected_status_codes,
591
590
  check_response_payload=check_response_payload,
592
591
  raise_scim_errors=raise_scim_errors,
593
592
  )
@@ -597,8 +596,8 @@ class SCIMClient:
597
596
  resource: Union[AnyResource, Dict],
598
597
  check_request_payload: bool = True,
599
598
  check_response_payload: bool = True,
600
- check_status_code: bool = True,
601
- raise_scim_errors: bool = False,
599
+ expected_status_codes: Optional[List[int]] = REPLACEMENT_RESPONSE_STATUS_CODES,
600
+ raise_scim_errors: bool = True,
602
601
  **kwargs,
603
602
  ) -> Union[AnyResource, Error, Dict]:
604
603
  """Perform a PUT request to replace a resource, as defined in
@@ -610,7 +609,8 @@ class SCIMClient:
610
609
  :code:`resource` is expected to be a dict that will be passed as-is in the request.
611
610
  :param check_response_payload: Whether to validate that the response payload is valid.
612
611
  If set, the raw payload will be returned.
613
- :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.
614
614
  :param raise_scim_errors: If :data:`True` and the server returned an
615
615
  :class:`~scim2_models.Error` object, a :class:`~scim2_client.SCIMResponseErrorObject`
616
616
  exception will be raised. If :data:`False` the error object is returned.
@@ -684,9 +684,7 @@ class SCIMClient:
684
684
 
685
685
  return self.check_response(
686
686
  response=response,
687
- expected_status_codes=(
688
- self.REPLACEMENT_RESPONSE_STATUS_CODES if check_status_code else None
689
- ),
687
+ expected_status_codes=expected_status_codes,
690
688
  expected_types=([resource.__class__] if check_request_payload else None),
691
689
  check_response_payload=check_response_payload,
692
690
  raise_scim_errors=raise_scim_errors,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scim2-client
3
- Version: 0.1.10
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
@@ -0,0 +1,6 @@
1
+ scim2_client/__init__.py,sha256=vgrTJZIqJLZc72XCJwYKrSCGUDkMZTJjCJiZkHERZGs,780
2
+ scim2_client/client.py,sha256=hFcpUG2jYtNb5e178lsf4-SubXb0opO9JgegR6Q-JZQ,27278
3
+ scim2_client/errors.py,sha256=Lu_4lPlbryqWYGLPmH2iWaVmlay8S4PrH6lUPIvcisA,4430
4
+ scim2_client-0.2.0.dist-info/METADATA,sha256=b5Q_wytHLRpCPga0hwYTVKgMmX0o9mFXuStQYtzNf50,3497
5
+ scim2_client-0.2.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
+ scim2_client-0.2.0.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- scim2_client/__init__.py,sha256=vgrTJZIqJLZc72XCJwYKrSCGUDkMZTJjCJiZkHERZGs,780
2
- scim2_client/client.py,sha256=f0Hgc6ghZ84FtaAHca7T7NV3OcmlaIbZCJ9xwAMPQX4,27120
3
- scim2_client/errors.py,sha256=Lu_4lPlbryqWYGLPmH2iWaVmlay8S4PrH6lUPIvcisA,4430
4
- scim2_client-0.1.10.dist-info/METADATA,sha256=TmDRSk37bNwBp3A2Sf3Rmd7n4DVKGHgm_zhtzkSzUIM,3498
5
- scim2_client-0.1.10.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
6
- scim2_client-0.1.10.dist-info/RECORD,,