sfq 0.0.30__py3-none-any.whl → 0.0.31__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.
sfq/__init__.py
CHANGED
@@ -10,6 +10,7 @@ import os
|
|
10
10
|
import re
|
11
11
|
import time
|
12
12
|
import warnings
|
13
|
+
import webbrowser
|
13
14
|
import xml.etree.ElementTree as ET
|
14
15
|
from collections import OrderedDict
|
15
16
|
from concurrent.futures import ThreadPoolExecutor, as_completed
|
@@ -99,7 +100,7 @@ class SFAuth:
|
|
99
100
|
access_token: Optional[str] = None,
|
100
101
|
token_expiration_time: Optional[float] = None,
|
101
102
|
token_lifetime: int = 15 * 60,
|
102
|
-
user_agent: str = "sfq/0.0.
|
103
|
+
user_agent: str = "sfq/0.0.31",
|
103
104
|
sforce_client: str = "_auto",
|
104
105
|
proxy: str = "_auto",
|
105
106
|
) -> None:
|
@@ -997,9 +998,10 @@ class SFAuth:
|
|
997
998
|
|
998
999
|
return combined_response or None
|
999
1000
|
|
1000
|
-
def _gen_soap_envelope(self, header: str, body: str) -> str:
|
1001
|
-
"""Generates a full SOAP envelope with all required namespaces for Salesforce
|
1002
|
-
|
1001
|
+
def _gen_soap_envelope(self, header: str, body: str, type: str) -> str:
|
1002
|
+
"""Generates a full SOAP envelope with all required namespaces for Salesforce API."""
|
1003
|
+
if type == "enterprise":
|
1004
|
+
return (
|
1003
1005
|
'<?xml version="1.0" encoding="UTF-8"?>'
|
1004
1006
|
"<soapenv:Envelope "
|
1005
1007
|
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '
|
@@ -1010,8 +1012,24 @@ class SFAuth:
|
|
1010
1012
|
f"{header}{body}"
|
1011
1013
|
"</soapenv:Envelope>"
|
1012
1014
|
)
|
1015
|
+
elif type == "tooling":
|
1016
|
+
return (
|
1017
|
+
'<?xml version="1.0" encoding="UTF-8"?>'
|
1018
|
+
"<soapenv:Envelope "
|
1019
|
+
'xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" '
|
1020
|
+
'xmlns:xsd="http://www.w3.org/2001/XMLSchema" '
|
1021
|
+
'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
|
1022
|
+
'xmlns="urn:tooling.soap.sforce.com" '
|
1023
|
+
'xmlns:mns="urn:metadata.tooling.soap.sforce.com" '
|
1024
|
+
'xmlns:sf="urn:sobject.tooling.soap.sforce.com">'
|
1025
|
+
f"{header}{body}"
|
1026
|
+
"</soapenv:Envelope>"
|
1027
|
+
)
|
1028
|
+
raise ValueError(
|
1029
|
+
f"Unsupported API type: {type}. Must be 'enterprise' or 'tooling'."
|
1030
|
+
)
|
1013
1031
|
|
1014
|
-
def _gen_soap_header(self):
|
1032
|
+
def _gen_soap_header(self) -> str:
|
1015
1033
|
"""This function generates the header for the SOAP request."""
|
1016
1034
|
headers = self._get_common_headers()
|
1017
1035
|
session_id = headers["Authorization"].split(" ")[1]
|
@@ -1099,7 +1117,7 @@ class SFAuth:
|
|
1099
1117
|
insert_list: List[Dict[str, Any]],
|
1100
1118
|
batch_size: int = 200,
|
1101
1119
|
max_workers: int = None,
|
1102
|
-
api_type: Literal["enterprise", "tooling"
|
1120
|
+
api_type: Literal["enterprise", "tooling"] = "enterprise",
|
1103
1121
|
) -> Optional[Dict[str, Any]]:
|
1104
1122
|
"""
|
1105
1123
|
Execute the Insert API to insert multiple records via SOAP calls.
|
@@ -1116,14 +1134,13 @@ class SFAuth:
|
|
1116
1134
|
endpoint += f"c/{self.api_version}"
|
1117
1135
|
elif api_type == "tooling":
|
1118
1136
|
endpoint += f"T/{self.api_version}"
|
1119
|
-
elif api_type == "metadata":
|
1120
|
-
endpoint += f"m/{self.api_version}"
|
1121
1137
|
else:
|
1122
1138
|
logger.error(
|
1123
|
-
"Invalid API type: %s. Must be one of: 'enterprise', 'tooling'
|
1139
|
+
"Invalid API type: %s. Must be one of: 'enterprise', 'tooling'.",
|
1124
1140
|
api_type,
|
1125
1141
|
)
|
1126
1142
|
return None
|
1143
|
+
endpoint = endpoint.replace('/v', '/') # handle API versioning in the endpoint
|
1127
1144
|
|
1128
1145
|
if isinstance(insert_list, dict):
|
1129
1146
|
insert_list = [insert_list]
|
@@ -1136,7 +1153,7 @@ class SFAuth:
|
|
1136
1153
|
def insert_chunk(chunk: List[Dict[str, Any]]) -> Optional[Dict[str, Any]]:
|
1137
1154
|
header = self._gen_soap_header()
|
1138
1155
|
body = self._gen_soap_body(sobject=sobject, method="create", data=chunk)
|
1139
|
-
envelope = self._gen_soap_envelope(header, body)
|
1156
|
+
envelope = self._gen_soap_envelope(header=header, body=body, type=api_type)
|
1140
1157
|
soap_headers = self._get_common_headers().copy()
|
1141
1158
|
soap_headers["Content-Type"] = "text/xml; charset=UTF-8"
|
1142
1159
|
soap_headers["SOAPAction"] = '""'
|
@@ -1197,4 +1214,14 @@ class SFAuth:
|
|
1197
1214
|
Perform cleanup operations for Apex debug logs.
|
1198
1215
|
"""
|
1199
1216
|
if apex_logs:
|
1200
|
-
self._debug_cleanup_apex_logs()
|
1217
|
+
self._debug_cleanup_apex_logs()
|
1218
|
+
|
1219
|
+
def open_frontdoor(self) -> None:
|
1220
|
+
"""
|
1221
|
+
This function opens the Salesforce Frontdoor URL in the default web browser.
|
1222
|
+
"""
|
1223
|
+
if not self.access_token:
|
1224
|
+
self._get_common_headers()
|
1225
|
+
sid = quote(self.access_token, safe="")
|
1226
|
+
frontdoor_url = f"{self.instance_url}/secur/frontdoor.jsp?sid={sid}"
|
1227
|
+
webbrowser.open(frontdoor_url)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
sfq/__init__.py,sha256=nVBedAMHbX95YE6FcdvjsH_BZ56Ekl855Q_HuIaYoG0,46792
|
2
|
+
sfq/_cometd.py,sha256=XimQEubmJwUmbWe85TxH_cuhGvWVuiHHrVr41tguuiI,10508
|
3
|
+
sfq/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
+
sfq-0.0.31.dist-info/METADATA,sha256=RMgCGs9B5xkc9Ci9zOMl3B5peAwdTBzvLExOYOqaclI,6899
|
5
|
+
sfq-0.0.31.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
+
sfq-0.0.31.dist-info/RECORD,,
|
sfq-0.0.30.dist-info/RECORD
DELETED
@@ -1,6 +0,0 @@
|
|
1
|
-
sfq/__init__.py,sha256=MpqXIfKQW1XRGBAh_uYBpdF5tj2Mxdzf3cCNO77yyd0,45630
|
2
|
-
sfq/_cometd.py,sha256=XimQEubmJwUmbWe85TxH_cuhGvWVuiHHrVr41tguuiI,10508
|
3
|
-
sfq/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
4
|
-
sfq-0.0.30.dist-info/METADATA,sha256=ieHDwbhGy16xT_kAIEWVnQIWxVHnMN1vxenlIrHypas,6899
|
5
|
-
sfq-0.0.30.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
6
|
-
sfq-0.0.30.dist-info/RECORD,,
|
File without changes
|