pyxecm 0.0.18__py3-none-any.whl → 0.0.19__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.

Potentially problematic release.


This version of pyxecm might be problematic. Click here for more details.

pyxecm/otds.py CHANGED
@@ -33,6 +33,12 @@ getLicensesForResource : Get list of licenses for a resource
33
33
  deleteLicenseFromResource : Delete a license from a resource
34
34
  assignUserToLicense : Assign an OTDS user to a product license (feature) in OTDS.
35
35
  assignPartitionToLicense: Assign an OTDS user partition to a license (feature) in OTDS.
36
+ getLicensedObjects: Return the licensed objects (users, groups, partitions) an OTDS for a
37
+ license + license feature associated with an OTDS resource (like "cs").
38
+ isUserLicensed: Check if a user is licensed for a license and license feature associated
39
+ with a particular OTDS resource.
40
+ isPartitionLicensed: Check if a user partition is licensed for a license and license feature
41
+ associated with a particular OTDS resource.
36
42
 
37
43
  addPartition : Add an OTDS partition
38
44
  getPartition : Get a partition with a specific name
@@ -405,10 +411,11 @@ class OTDS:
405
411
  retries += 1
406
412
  else:
407
413
  logger.error(
408
- "Failed to add product license -> {} for product -> {}; error -> {}".format(
414
+ "Failed to add product license -> {} for product -> {}; error -> {} ({})".format(
409
415
  path_to_license_file,
410
416
  product_description,
411
417
  response.text,
418
+ response.status_code,
412
419
  )
413
420
  )
414
421
  return None
@@ -454,8 +461,8 @@ class OTDS:
454
461
  retries += 1
455
462
  else:
456
463
  logger.error(
457
- "Failed to get license for resource -> {}; error -> {}".format(
458
- resource_id, response.text
464
+ "Failed to get license for resource -> {}; error -> {} ({})".format(
465
+ resource_id, response.text, response.status_code
459
466
  )
460
467
  )
461
468
  return None
@@ -494,8 +501,8 @@ class OTDS:
494
501
  retries += 1
495
502
  else:
496
503
  logger.error(
497
- "Failed to delete license -> {} for resource -> {}; error -> {}".format(
498
- license_id, resource_id, response.text
504
+ "Failed to delete license -> {} for resource -> {}; error -> {} ({})".format(
505
+ license_id, resource_id, response.text, response.status_code
499
506
  )
500
507
  )
501
508
  return False
@@ -584,10 +591,11 @@ class OTDS:
584
591
  retries += 1
585
592
  else:
586
593
  logger.error(
587
- "Failed to add license feature -> {} associated with resource -> {} for user -> {}; status code -> {}".format(
594
+ "Failed to add license feature -> {} associated with resource -> {} to user -> {}; error -> {} ({})".format(
588
595
  license_feature,
589
596
  resource_id,
590
597
  user_id,
598
+ response.text,
591
599
  response.status_code,
592
600
  )
593
601
  )
@@ -616,7 +624,26 @@ class OTDS:
616
624
  """
617
625
 
618
626
  licenses = self.getLicensesForResource(resource_id)
627
+ if not licenses:
628
+ logger.error(
629
+ "Resource with ID -> {} does not exist or has no licenses".format(
630
+ resource_id
631
+ )
632
+ )
633
+ return False
619
634
 
635
+ # licenses have this format:
636
+ # {
637
+ # '_oTLicenseType': 'NON-PRODUCTION',
638
+ # '_oTLicenseResource': '7382094f-a434-4714-9696-82864b6803da',
639
+ # '_oTLicenseResourceName': 'cs',
640
+ # '_oTLicenseProduct': 'EXTENDED_ECM',
641
+ # 'name': 'EXTENDED_ECM¹7382094f-a434-4714-9696-82864b6803da',
642
+ # 'location': 'cn=EXTENDED_ECM¹7382094f-a434-4714-9696-82864b6803da,ou=Licenses,dc=identity,dc=opentext,dc=net',
643
+ # 'id': 'cn=EXTENDED_ECM¹7382094f-a434-4714-9696-82864b6803da,ou=Licenses,dc=identity,dc=opentext,dc=net',
644
+ # 'description': 'CS license',
645
+ # 'values': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, ...]
646
+ # }
620
647
  for lic in licenses:
621
648
  if lic["_oTLicenseProduct"] == license_name:
622
649
  license_location = lic["id"]
@@ -642,7 +669,11 @@ class OTDS:
642
669
 
643
670
  logger.info(
644
671
  "Assign license feature -> {} of license -> {} associated with resource -> {} to partition -> {}; calling -> {}".format(
645
- license_feature, license_location, resource_id, partition_name, request_url
672
+ license_feature,
673
+ license_location,
674
+ resource_id,
675
+ partition_name,
676
+ request_url,
646
677
  )
647
678
  )
648
679
 
@@ -668,10 +699,11 @@ class OTDS:
668
699
  retries += 1
669
700
  else:
670
701
  logger.error(
671
- "Failed to add license feature -> {} associated with resource -> {} for partition -> {}; status code -> {}".format(
702
+ "Failed to add license feature -> {} associated with resource -> {} to partition -> {}; error -> {} ({})".format(
672
703
  license_feature,
673
704
  resource_id,
674
705
  partition_name,
706
+ response.text,
675
707
  response.status_code,
676
708
  )
677
709
  )
@@ -679,6 +711,246 @@ class OTDS:
679
711
 
680
712
  # end method definition
681
713
 
714
+ def getLicensedObjects(
715
+ self,
716
+ resource_id: str,
717
+ license_feature: str,
718
+ license_name: str,
719
+ ):
720
+ """Return the licensed objects (users, groups, partitions) in OTDS for a license + license feature
721
+ associated with an OTDS resource (like "cs").
722
+
723
+ Args:
724
+ resource_id (string): OTDS resource ID (this is ID not the resource name!)
725
+ license_feature (string): name of the license feature, e.g. "X2" or "ADDON_ENGINEERING"
726
+ license_name (string): name of the license to assign, e.g. "EXTENDED_ECM" or "INTELLGENT_VIEWIMG"
727
+ Returns:
728
+ dict: data structure of licensed objects
729
+
730
+ Example return value:
731
+ {
732
+ 'status': 0,
733
+ 'displayString': 'Success',
734
+ 'exceptions': None,
735
+ 'retValue': 0,
736
+ 'listGroupsResults': {'groups': [...], 'actualPageSize': 0, 'nextPageCookie': None, 'requestedPageSize': 250},
737
+ 'listUsersResults': {'users': [...], 'actualPageSize': 53, 'nextPageCookie': None, 'requestedPageSize': 250},
738
+ 'listUserPartitionResult': {'_userPartitions': [...], 'warningMessage': None, 'actualPageSize': 0, 'nextPageCookie': None, 'requestedPageSize': 250},
739
+ 'version': 1
740
+ }
741
+ """
742
+
743
+ licenses = self.getLicensesForResource(resource_id)
744
+ if not licenses:
745
+ logger.error(
746
+ "Resource with ID -> {} does not exist or has no licenses".format(
747
+ resource_id
748
+ )
749
+ )
750
+ return False
751
+
752
+ # licenses have this format:
753
+ # {
754
+ # '_oTLicenseType': 'NON-PRODUCTION',
755
+ # '_oTLicenseResource': '7382094f-a434-4714-9696-82864b6803da',
756
+ # '_oTLicenseResourceName': 'cs',
757
+ # '_oTLicenseProduct': 'EXTENDED_ECM',
758
+ # 'name': 'EXTENDED_ECM¹7382094f-a434-4714-9696-82864b6803da',
759
+ # 'location': 'cn=EXTENDED_ECM¹7382094f-a434-4714-9696-82864b6803da,ou=Licenses,dc=identity,dc=opentext,dc=net',
760
+ # 'id': 'cn=EXTENDED_ECM¹7382094f-a434-4714-9696-82864b6803da,ou=Licenses,dc=identity,dc=opentext,dc=net',
761
+ # 'description': 'CS license',
762
+ # 'values': [{...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, {...}, ...]
763
+ # }
764
+ for lic in licenses:
765
+ if lic["_oTLicenseProduct"] == license_name:
766
+ license_location = lic["location"]
767
+
768
+ try:
769
+ license_location
770
+ except UnboundLocalError:
771
+ logger.error(
772
+ "Cannot find license -> {} for resource -> {}".format(
773
+ license_name, resource_id
774
+ )
775
+ )
776
+ return False
777
+
778
+ request_url = (
779
+ self.licenseUrl()
780
+ + "/object/"
781
+ + license_location
782
+ + "?counter="
783
+ + license_feature
784
+ )
785
+
786
+ logger.info(
787
+ "Get licensed objects for license -> {} and license feature -> {} associated with resource -> {}; calling -> {}".format(
788
+ license_name,
789
+ license_feature,
790
+ resource_id,
791
+ request_url,
792
+ )
793
+ )
794
+
795
+ retries = 0
796
+ while True:
797
+ response = requests.get(
798
+ request_url,
799
+ headers=requestHeaders,
800
+ cookies=self.cookie(),
801
+ )
802
+ if response.ok:
803
+ return self.parseRequestResponse(response)
804
+ # Check if Session has expired - then re-authenticate and try once more
805
+ elif response.status_code == 401 and retries == 0:
806
+ logger.warning("Session has expired - try to re-authenticate...")
807
+ self.authenticate(True)
808
+ retries += 1
809
+ else:
810
+ logger.error(
811
+ "Failed to get licensed objects for license -> {} and license feature -> {} associated with resource -> {}; error -> {} ({})".format(
812
+ license_name,
813
+ license_feature,
814
+ resource_id,
815
+ response.text,
816
+ response.status_code,
817
+ )
818
+ )
819
+ return None
820
+
821
+ # end method definition
822
+
823
+ def isUserLicensed(self, user_name: str, resource_id: str, license_feature: str, license_name: str) -> bool:
824
+ """Check if a user is licensed for a license and license feature associated with a particular OTDS resource.
825
+
826
+ Args:
827
+ user_name (str): login name of the OTDS user
828
+ resource_id (string): OTDS resource ID (this is ID not the resource name!)
829
+ license_feature (string): name of the license feature, e.g. "X2" or "ADDON_ENGINEERING"
830
+ license_name (string): name of the license to assign, e.g. "EXTENDED_ECM" or "INTELLGENT_VIEWIMG"
831
+
832
+ Returns:
833
+ bool: True if the user is licensed and False otherwise
834
+ """
835
+
836
+ response = self.getLicensedObjects(
837
+ resource_id=resource_id,
838
+ license_feature=license_feature,
839
+ license_name=license_name,
840
+ )
841
+
842
+ if not response or not response["listUsersResults"]:
843
+ return False
844
+
845
+ users = response["listUsersResults"]["users"]
846
+
847
+ if not users:
848
+ return False
849
+
850
+ user = next(
851
+ (
852
+ item
853
+ for item in users
854
+ if item["name"] == user_name
855
+ ),
856
+ None,
857
+ )
858
+
859
+ if user:
860
+ return True
861
+
862
+ return False
863
+
864
+ # end method definition
865
+
866
+ def isGroupLicensed(self, group_name: str, resource_id: str, license_feature: str, license_name: str) -> bool:
867
+ """Check if a group is licensed for a license and license feature associated with a particular OTDS resource.
868
+
869
+ Args:
870
+ group_name (str): name of the OTDS user group
871
+ resource_id (string): OTDS resource ID (this is ID not the resource name!)
872
+ license_feature (string): name of the license feature, e.g. "X2" or "ADDON_ENGINEERING"
873
+ license_name (string): name of the license to assign, e.g. "EXTENDED_ECM" or "INTELLGENT_VIEWIMG"
874
+
875
+ Returns:
876
+ bool: True if the group is licensed and False otherwise
877
+ """
878
+
879
+ response = self.getLicensedObjects(
880
+ resource_id=resource_id,
881
+ license_feature=license_feature,
882
+ license_name=license_name,
883
+ )
884
+
885
+ if not response or not response["listGroupsResults"]:
886
+ return False
887
+
888
+ groups = response["listGroupsResults"]["groups"]
889
+
890
+ if not groups:
891
+ return False
892
+
893
+ group = next(
894
+ (
895
+ item
896
+ for item in groups
897
+ if item["name"] == group_name
898
+ ),
899
+ None,
900
+ )
901
+
902
+ if group:
903
+ return True
904
+
905
+ return False
906
+
907
+ # end method definition
908
+
909
+ def isPartitionLicensed(
910
+ self, partition_name: str, resource_id: str, license_feature: str, license_name: str
911
+ ):
912
+ """Check if a user is licensed for a license and license feature associated with a particular OTDS resource.
913
+
914
+ Args:
915
+ partition_name (str): name of the OTDS user partition, e.g. "Content Server Members"
916
+ resource_id (string): OTDS resource ID (this is ID not the resource name!)
917
+ license_feature (string): name of the license feature, e.g. "X2" or "ADDON_ENGINEERING"
918
+ license_name (string): name of the license to assign, e.g. "EXTENDED_ECM" or "INTELLGENT_VIEWIMG"
919
+
920
+ Returns:
921
+ bool: True if the partition is licensed and False otherwise
922
+ """
923
+
924
+ response = self.getLicensedObjects(
925
+ resource_id=resource_id,
926
+ license_feature=license_feature,
927
+ license_name=license_name,
928
+ )
929
+
930
+ if not response or not response["listUserPartitionResult"]:
931
+ return False
932
+
933
+ partitions = response["listUserPartitionResult"]["_userPartitions"]
934
+
935
+ if not partitions:
936
+ return False
937
+
938
+ partition = next(
939
+ (
940
+ item
941
+ for item in partitions
942
+ if item["name"] == partition_name
943
+ ),
944
+ None,
945
+ )
946
+
947
+ if partition:
948
+ return True
949
+
950
+ return False
951
+
952
+ # end method definition
953
+
682
954
  def addPartition(self, name: str, description: str) -> dict:
683
955
  """Add a new user partition to OTDS
684
956
 
@@ -715,8 +987,8 @@ class OTDS:
715
987
  retries += 1
716
988
  else:
717
989
  logger.error(
718
- "Failed to add user partition -> {}; error -> {}".format(
719
- name, response.text
990
+ "Failed to add user partition -> {}; error -> {} ({})".format(
991
+ name, response.text, response.status_code
720
992
  )
721
993
  )
722
994
  return None
@@ -754,8 +1026,8 @@ class OTDS:
754
1026
  else:
755
1027
  if show_error:
756
1028
  logger.error(
757
- "Failed to get partition -> {}; warning -> {}".format(
758
- name, response.text
1029
+ "Failed to get partition -> {}; warning -> {} ({})".format(
1030
+ name, response.text, response.status_code
759
1031
  )
760
1032
  )
761
1033
  return None
@@ -821,7 +1093,9 @@ class OTDS:
821
1093
  retries += 1
822
1094
  else:
823
1095
  logger.error(
824
- "Failed to add user -> {}; error -> {}".format(name, response.text)
1096
+ "Failed to add user -> {}; error -> {} ({})".format(
1097
+ name, response.text, response.status_code
1098
+ )
825
1099
  )
826
1100
  return None
827
1101
 
@@ -859,8 +1133,8 @@ class OTDS:
859
1133
  retries += 1
860
1134
  else:
861
1135
  logger.error(
862
- "Failed to get user -> {}; error -> {}".format(
863
- user_id, response.text
1136
+ "Failed to get user -> {}; error -> {} ({})".format(
1137
+ user_id, response.text, response.status_code
864
1138
  )
865
1139
  )
866
1140
  return None
@@ -911,8 +1185,8 @@ class OTDS:
911
1185
  retries += 1
912
1186
  else:
913
1187
  logger.error(
914
- "Failed to update user -> {}; error -> {}".format(
915
- user_id, response.text
1188
+ "Failed to update user -> {}; error -> {} ({})".format(
1189
+ user_id, response.text, response.status_code
916
1190
  )
917
1191
  )
918
1192
  return None
@@ -951,8 +1225,8 @@ class OTDS:
951
1225
  retries += 1
952
1226
  else:
953
1227
  logger.error(
954
- "Failed to delete user -> {}; error -> {}".format(
955
- user_id, response.text
1228
+ "Failed to delete user -> {}; error -> {} ({})".format(
1229
+ user_id, response.text, response.status_code
956
1230
  )
957
1231
  )
958
1232
  return False
@@ -996,8 +1270,8 @@ class OTDS:
996
1270
  retries += 1
997
1271
  else:
998
1272
  logger.error(
999
- "Failed to reset password for user -> {}; error -> {}".format(
1000
- user_id, response.text
1273
+ "Failed to reset password for user -> {}; error -> {} ({})".format(
1274
+ user_id, response.text, response.status_code
1001
1275
  )
1002
1276
  )
1003
1277
  return False
@@ -1047,7 +1321,9 @@ class OTDS:
1047
1321
  retries += 1
1048
1322
  else:
1049
1323
  logger.error(
1050
- "Failed to add group -> {}; error -> {}".format(name, response.text)
1324
+ "Failed to add group -> {}; error -> {} ({})".format(
1325
+ name, response.text, response.status_code
1326
+ )
1051
1327
  )
1052
1328
  return None
1053
1329
 
@@ -1096,8 +1372,8 @@ class OTDS:
1096
1372
  retries += 1
1097
1373
  else:
1098
1374
  logger.error(
1099
- "Failed to get group -> {}; error -> {}".format(
1100
- group, response.text
1375
+ "Failed to get group -> {}; error -> {} ({})".format(
1376
+ group, response.text, response.status_code
1101
1377
  )
1102
1378
  )
1103
1379
  return None
@@ -1141,8 +1417,8 @@ class OTDS:
1141
1417
  retries += 1
1142
1418
  else:
1143
1419
  logger.error(
1144
- "Failed to add user -> {} to group -> {}; error -> {}".format(
1145
- user, group, response.text
1420
+ "Failed to add user -> {} to group -> {}; error -> {} ({})".format(
1421
+ user, group, response.text, response.status_code
1146
1422
  )
1147
1423
  )
1148
1424
  return False
@@ -1187,8 +1463,8 @@ class OTDS:
1187
1463
  retries += 1
1188
1464
  else:
1189
1465
  logger.error(
1190
- "Failed to add group -> {} to parent group -> {}; error -> {}".format(
1191
- group, parent_group, response.text
1466
+ "Failed to add group -> {} to parent group -> {}; error -> {} ({})".format(
1467
+ group, parent_group, response.text, response.status_code
1192
1468
  )
1193
1469
  )
1194
1470
  return False
@@ -1249,8 +1525,8 @@ class OTDS:
1249
1525
  retries += 1
1250
1526
  else:
1251
1527
  logger.error(
1252
- "Failed to add resource -> {}; error -> {}".format(
1253
- name, response.text
1528
+ "Failed to add resource -> {}; error -> {} ({})".format(
1529
+ name, response.text, response.status_code
1254
1530
  )
1255
1531
  )
1256
1532
  return None
@@ -1300,7 +1576,9 @@ class OTDS:
1300
1576
 
1301
1577
  # end method definition
1302
1578
 
1303
- def updateResource(self, name: str, resource: object, show_error: bool = True) -> dict:
1579
+ def updateResource(
1580
+ self, name: str, resource: object, show_error: bool = True
1581
+ ) -> dict:
1304
1582
  """Update an existing OTDS resource
1305
1583
 
1306
1584
  Args:
@@ -1379,8 +1657,8 @@ class OTDS:
1379
1657
  retries += 1
1380
1658
  else:
1381
1659
  logger.error(
1382
- "Failed to activate resource -> {}; error -> {}".format(
1383
- resource_id, response.text
1660
+ "Failed to activate resource -> {}; error -> {} ({})".format(
1661
+ resource_id, response.text, response.status_code
1384
1662
  )
1385
1663
  )
1386
1664
  return None
@@ -1413,7 +1691,9 @@ class OTDS:
1413
1691
  retries += 1
1414
1692
  else:
1415
1693
  logger.error(
1416
- "Failed to retrieve access roles; error -> {}".format(response.text)
1694
+ "Failed to retrieve access roles; error -> {} ({})".format(
1695
+ response.text, response.status_code
1696
+ )
1417
1697
  )
1418
1698
  return None
1419
1699
 
@@ -1448,8 +1728,8 @@ class OTDS:
1448
1728
  retries += 1
1449
1729
  else:
1450
1730
  logger.error(
1451
- "Failed to retrieve access role -> {}; error -> {}".format(
1452
- name, response.text
1731
+ "Failed to retrieve access role -> {}; error -> {} ({})".format(
1732
+ name, response.text, response.status_code
1453
1733
  )
1454
1734
  )
1455
1735
  return None
@@ -1501,15 +1781,17 @@ class OTDS:
1501
1781
  retries += 1
1502
1782
  else:
1503
1783
  logger.error(
1504
- "Failed to add partition -> {} to access role -> {}; error -> {}".format(
1505
- partition, access_role, response.text
1784
+ "Failed to add partition -> {} to access role -> {}; error -> {} ({})".format(
1785
+ partition, access_role, response.text, response.status_code
1506
1786
  )
1507
1787
  )
1508
1788
  return False
1509
1789
 
1510
1790
  # end method definition
1511
1791
 
1512
- def addUserToAccessRole(self, access_role: str, user_id: str, location: str = "") -> bool:
1792
+ def addUserToAccessRole(
1793
+ self, access_role: str, user_id: str, location: str = ""
1794
+ ) -> bool:
1513
1795
  """Add an OTDS user to an OTDS access role
1514
1796
 
1515
1797
  Args:
@@ -1574,15 +1856,17 @@ class OTDS:
1574
1856
  retries += 1
1575
1857
  else:
1576
1858
  logger.error(
1577
- "Failed to add user -> {} to access role -> {}; error -> {}".format(
1578
- user_id, access_role, response.text
1859
+ "Failed to add user -> {} to access role -> {}; error -> {} ({})".format(
1860
+ user_id, access_role, response.text, response.status_code
1579
1861
  )
1580
1862
  )
1581
1863
  return False
1582
1864
 
1583
1865
  # end method definition
1584
1866
 
1585
- def addGroupToAccessRole(self, access_role: str, group: str, location: str = "") -> bool:
1867
+ def addGroupToAccessRole(
1868
+ self, access_role: str, group: str, location: str = ""
1869
+ ) -> bool:
1586
1870
  """Add an OTDS group to an OTDS access role
1587
1871
 
1588
1872
  Args:
@@ -1646,8 +1930,8 @@ class OTDS:
1646
1930
  retries += 1
1647
1931
  else:
1648
1932
  logger.error(
1649
- "Failed to add group -> {} to access role -> {}; error -> {}".format(
1650
- group, access_role, response.text
1933
+ "Failed to add group -> {} to access role -> {}; error -> {} ({})".format(
1934
+ group, access_role, response.text, response.status_code
1651
1935
  )
1652
1936
  )
1653
1937
  return False
@@ -1703,8 +1987,8 @@ class OTDS:
1703
1987
  retries += 1
1704
1988
  else:
1705
1989
  logger.error(
1706
- "Failed to update access role -> {}; error -> {}".format(
1707
- name, response.text
1990
+ "Failed to update access role -> {}; error -> {} ({})".format(
1991
+ name, response.text, response.status_code
1708
1992
  )
1709
1993
  )
1710
1994
  return None
@@ -1760,8 +2044,8 @@ class OTDS:
1760
2044
  retries += 1
1761
2045
  else:
1762
2046
  logger.error(
1763
- "Failed to add system attribute -> {} with value -> {}; error -> {}".format(
1764
- name, value, response.text
2047
+ "Failed to add system attribute -> {} with value -> {}; error -> {} ({})".format(
2048
+ name, value, response.text, response.status_code
1765
2049
  )
1766
2050
  )
1767
2051
  return None
@@ -1795,8 +2079,8 @@ class OTDS:
1795
2079
  retries += 1
1796
2080
  else:
1797
2081
  logger.error(
1798
- "Failed to retrieve trusted sites; error -> {}".format(
1799
- response.text
2082
+ "Failed to retrieve trusted sites; error -> {} ({})".format(
2083
+ response.text, response.status_code
1800
2084
  )
1801
2085
  )
1802
2086
  return None
@@ -1837,12 +2121,12 @@ class OTDS:
1837
2121
  )
1838
2122
  if not response.ok:
1839
2123
  logger.error(
1840
- "Failed to add trusted site -> {}; error -> {}".format(
1841
- trusted_site, response.text
2124
+ "Failed to add trusted site -> {}; error -> {} ({})".format(
2125
+ trusted_site, response.text, response.status_code
1842
2126
  )
1843
2127
  )
1844
2128
  return None
1845
- return response # don't parse it!
2129
+ return response # don't parse it!
1846
2130
 
1847
2131
  # end method definition
1848
2132
 
@@ -1921,7 +2205,11 @@ class OTDS:
1921
2205
  cookies=self.cookie(),
1922
2206
  )
1923
2207
  if not response.ok:
1924
- logger.error("Failed to enable audit; error -> {}".format(response.text))
2208
+ logger.error(
2209
+ "Failed to enable audit; error -> {} ({})".format(
2210
+ response.text, response.status_code
2211
+ )
2212
+ )
1925
2213
  return response
1926
2214
 
1927
2215
  # end method definition
@@ -1993,8 +2281,8 @@ class OTDS:
1993
2281
  retries += 1
1994
2282
  else:
1995
2283
  logger.error(
1996
- "Failed to add OAuth client -> {}; error -> {}".format(
1997
- client_id, response.text
2284
+ "Failed to add OAuth client -> {}; error -> {} ({})".format(
2285
+ client_id, response.text, response.status_code
1998
2286
  )
1999
2287
  )
2000
2288
  return None
@@ -2032,8 +2320,8 @@ class OTDS:
2032
2320
  else:
2033
2321
  if show_error:
2034
2322
  logger.error(
2035
- "Failed to get oauth client -> {}; error -> {}".format(
2036
- client_id, response.text
2323
+ "Failed to get oauth client -> {}; error -> {} ({})".format(
2324
+ client_id, response.text, response.status_code
2037
2325
  )
2038
2326
  )
2039
2327
  return None
@@ -2068,8 +2356,8 @@ class OTDS:
2068
2356
  retries += 1
2069
2357
  else:
2070
2358
  logger.error(
2071
- "Failed to update OAuth client -> {}; error -> {}".format(
2072
- client_id, response.text
2359
+ "Failed to update OAuth client -> {}; error -> {} ({})".format(
2360
+ client_id, response.text, response.status_code
2073
2361
  )
2074
2362
  )
2075
2363
  return None
@@ -2108,8 +2396,11 @@ class OTDS:
2108
2396
  retries += 1
2109
2397
  else:
2110
2398
  logger.error(
2111
- "Failed to retrieve role -> {}; url -> {} : error -> {}".format(
2112
- access_role_name, accessRolesUrl, response.text
2399
+ "Failed to retrieve role -> {}; url -> {} : error -> {} ({})".format(
2400
+ access_role_name,
2401
+ accessRolesUrl,
2402
+ response.text,
2403
+ response.status_code,
2113
2404
  )
2114
2405
  )
2115
2406
  return None
@@ -2138,8 +2429,8 @@ class OTDS:
2138
2429
  oauthClientLocation = response_dict["location"]
2139
2430
  else:
2140
2431
  logger.error(
2141
- "Failed to get partition info for OAuthClients; url -> {} : error -> {}".format(
2142
- oauthPartitionsUrl, partitionsResponse.text
2432
+ "Failed to get partition info for OAuthClients; url -> {} : error -> {} ({})".format(
2433
+ oauthPartitionsUrl, partitionsResponse.text, response.status_code
2143
2434
  )
2144
2435
  )
2145
2436
  return None
@@ -2328,8 +2619,8 @@ class OTDS:
2328
2619
  retries += 1
2329
2620
  else:
2330
2621
  logger.error(
2331
- "Failed to add SAML auth handler -> {}; error -> {}".format(
2332
- name, response.text
2622
+ "Failed to add SAML auth handler -> {}; error -> {} ({})".format(
2623
+ name, response.text, response.status_code
2333
2624
  )
2334
2625
  )
2335
2626
  return None
@@ -2425,8 +2716,8 @@ class OTDS:
2425
2716
  )
2426
2717
  if not response.ok:
2427
2718
  logger.error(
2428
- "Failed to add SAP auth handler -> {}; error -> {}".format(
2429
- name, response.text
2719
+ "Failed to add SAP auth handler -> {}; error -> {} ({})".format(
2720
+ name, response.text, response.status_code
2430
2721
  )
2431
2722
  )
2432
2723
  return None
@@ -2522,8 +2813,8 @@ class OTDS:
2522
2813
  )
2523
2814
  if not response.ok:
2524
2815
  logger.error(
2525
- "Failed to upload certificate file -> {} for SAP auth handler -> {}; error -> {}".format(
2526
- certificate_file, name, response.text
2816
+ "Failed to upload certificate file -> {} for SAP auth handler -> {}; error -> {} ({})".format(
2817
+ certificate_file, name, response.text, response.status_code
2527
2818
  )
2528
2819
  )
2529
2820
  return None
@@ -2927,8 +3218,8 @@ class OTDS:
2927
3218
  retries += 1
2928
3219
  else:
2929
3220
  logger.error(
2930
- "Failed to add OAuth auth handler -> {}; error -> {}".format(
2931
- name, response.text
3221
+ "Failed to add OAuth auth handler -> {}; error -> {} ({})".format(
3222
+ name, response.text, response.status_code
2932
3223
  )
2933
3224
  )
2934
3225
  return None
@@ -2947,8 +3238,8 @@ class OTDS:
2947
3238
  resource = self.getResource(resource_name)
2948
3239
  if not resource:
2949
3240
  logger.error(
2950
- "Resource -> {} not found - cannot consolidate; error -> {}".format(
2951
- resource_name
3241
+ "Resource -> {} not found - cannot consolidate; error -> {} ({})".format(
3242
+ resource_name, response.text, response.status_code
2952
3243
  )
2953
3244
  )
2954
3245
  return False
@@ -2989,7 +3280,11 @@ class OTDS:
2989
3280
  self.authenticate(True)
2990
3281
  retries += 1
2991
3282
  else:
2992
- logger.error("Failed to consolidate; error -> {}".format(response.text))
3283
+ logger.error(
3284
+ "Failed to consolidate; error -> {} ({})".format(
3285
+ response.text, response.status_code
3286
+ )
3287
+ )
2993
3288
  return False
2994
3289
 
2995
3290
  # end method definition
@@ -3094,8 +3389,8 @@ class OTDS:
3094
3389
  retries += 1
3095
3390
  else:
3096
3391
  logger.error(
3097
- "Failed to set impersonation for OAuth Client -> {}; error -> {}".format(
3098
- client_id, response.text
3392
+ "Failed to set impersonation for OAuth Client -> {}; error -> {} ({})".format(
3393
+ client_id, response.text, response.status_code
3099
3394
  )
3100
3395
  )
3101
3396
  return False