本文整理汇总了Python中zeep.Client方法的典型用法代码示例。如果您正苦于以下问题:Python zeep.Client方法的具体用法?Python zeep.Client怎么用?Python zeep.Client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类zeep
的用法示例。
在下文中一共展示了zeep.Client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: list_custom_attributes_command
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def list_custom_attributes_command(client: Client) -> Tuple[str, dict, dict]:
raw_custom_attributes_list = client.service.listCustomAttributes()
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_custom_attributes_list:
custom_attributes_list = helpers.serialize_object(raw_custom_attributes_list)
raw_response = custom_attributes_list
outputs: list = [{'Custom Attribute': custom_attribute} for custom_attribute in custom_attributes_list]
human_readable = tableToMarkdown('Symantec DLP custom attributes', outputs, removeNull=True)
else:
human_readable = 'No custom attributes found.'
return human_readable, entry_context, raw_response
示例2: __init__
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def __init__(
self,
wsdl_url,
key_data,
cert_data,
tbk_cert_data,
password=None,
transport_timeout=300,
):
super(ZeepSoapClient, self).__init__(
wsdl_url, key_data, cert_data, tbk_cert_data
)
self.wsse = ZeepWsseSignature.init_from_data(
key_data, cert_data, tbk_cert_data, password=password
)
self.transport_timeout = transport_timeout
self.transport = zeep.transports.Transport(timeout=self.transport_timeout)
self.history = zeep.plugins.HistoryPlugin()
self.client = zeep.Client(
wsdl_url, wsse=self.wsse, transport=self.transport, plugins=[self.history]
)
示例3: list_incident_status_command
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def list_incident_status_command(client: Client) -> Tuple[str, dict, dict]:
raw_incident_status_list = client.service.listIncidentStatus()
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incident_status_list:
incident_status_list = helpers.serialize_object(raw_incident_status_list)
raw_response = incident_status_list
outputs: list = [{'Incident Status': incident_status} for incident_status in incident_status_list]
human_readable = tableToMarkdown('Symantec DLP incident status', outputs, removeNull=True)
else:
human_readable = 'No incident status found.'
return human_readable, entry_context, raw_response
示例4: create_user_bse
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def create_user_bse(client_code):
'''
Creates a user on BSEStar (called client in bse lingo)
- Initializes SOAP client zeep
- Gets one-time password from BSEStar to query its endpoints
- Prepares fields to be sent to BSEStar user creation and fatca endpoints
- Posts the requests
'''
## initialise the zeep client for order wsdl
client = zeep.Client(wsdl=WSDL_UPLOAD_URL[settings.LIVE])
set_soap_logging()
## get the password
pass_dict = soap_get_password_upload(client)
## prepare the user record
bse_user = prepare_user_param(client_code)
## post the user creation request
user_response = soap_create_user(client, bse_user, pass_dict)
## TODO: Log the soap request and response post the user creation request
pass_dict = soap_get_password_upload(client)
bse_fatca = prepare_fatca_param(client_code)
fatca_response = soap_create_fatca(client, bse_fatca, pass_dict)
## TODO: Log the soap request and response post the fatca creation request
示例5: create_mandate_bse
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def create_mandate_bse(client_code, amount):
'''
Creates mandate for user for a specific amount
Called before creating an SIP transaction on BSEStar because
every SIP transaction requires a mandate
'''
## initialise the zeep client for wsdl
client = zeep.Client(wsdl=WSDL_UPLOAD_URL[settings.LIVE])
set_soap_logging()
## get the password
pass_dict = soap_get_password_upload(client)
## prepare the mandate record
bse_mandate = prepare_mandate_param(client_code, amount)
## post the mandate creation request
mandate_id = soap_create_mandate(client, bse_mandate, pass_dict)
return mandate_id
示例6: __init__
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def __init__(self, hostname=None, username=None, password=None):
"""
:param hostname:
Checkmarx hostname
:param username:
Checkmarx username
:param password:
Checkmarx password
"""
self.logger = configure_logging(logging.getLogger(__name__))
self.hostname = hostname
self.username = username
self.password = password
self.resolver_url = "%s/cxwebinterface/cxwsresolver.asmx?wsdl" % self.hostname
session = Session()
session.verify = False
self.transport = Transport(session=session)
try:
self._resolver_client = Client(self.resolver_url, transport=self.transport)
except Exception as error:
self.logger.error("Checkmarx connection failed: {error}".format(error=error))
raise ConnectionError(f"Checkmarx connection failed. Wrong or inaccessible hostname: {hostname}") from None
self.session_id = None
self.clients = {}
示例7: get_client
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def get_client(self, client_type='SDK'):
"""
Connect to Checkmarx client
:param client_type:
:return:
"""
if client_type in self.clients:
return self.clients[client_type]
try:
client_url = self.get_client_url(client_type)
client = Client(client_url + "?wsdl", transport=self.transport, strict=False)
credentials = {'User': self.username, 'Pass': self.password}
login = client.service.Login(credentials, 1033)
if not login.IsSuccesfull:
raise AssertionError(f"Unable to login in Checkmarx. \n"
f"Please double check CX_PASSWORD and CX_USER.")
if self.session_id is None:
self.session_id = login.SessionId
self.clients[client_type] = client
return client
except ConnectionError as error:
self.logger.critical(
"Checkmarx connection failed. Wrong or inaccessible hostname: {error}".format(error=error))
return False, False
示例8: __init__
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def __init__(self, name, session, wsdl_url, authentication, proxy_url=None):
"""
:param name: Name of this API
:type name: ``str``
:param session: HTTP session to use for communication
:type session: :class:`requests.Session`
:param wsdl_url: Path to the WSDL
:type wsdl_url: ``str``
:param authentication: Authentication configuration
:type authentication: :class:`workday.auth.BaseAuthentication`
:param proxy_url: (Optional) HTTP Proxy URL
:type proxy_url: ``str``
"""
auth_kwargs = authentication.kwargs
self._client = zeep.Client(
wsdl=wsdl_url,
transport=zeep.transports.Transport(session=session),
**auth_kwargs
)
示例9: gethostrecordwithhint
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def gethostrecordwithhint(bam_url, login_user, login_password, host_record_name):
"""get the host record FQDN and return the entity details
"""
records=""
try:
# api session
client = Client(bam_url)
# login
client.service.login(login_user,login_password)
# get the host record details
records = client.service.getHostRecordsByHint(0,10,"hint="+host_record_name+"|")
# logout of BAM
client.service.logout()
except zeep.exceptions.Fault as e:
print(e.message)
logging.exception(e)
sys.exit(1)
# return the records from function
return records
示例10: deletehostrecord
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def deletehostrecord(bam_url, login_user, login_password, host_record):
"""Delete host record
"""
# api session
client = Client(bam_url)
# login
client.service.login(login_user,login_password)
# get the host record details
print("You are requesting to delete:")
print(host_record)
answer = input("Do you want to proceed (y (yes) or n (no))? ")
if answer.lower() == "y":
deletion = client.service.deleteWithOptions(host_record['id'],
"deleteOrphanedIPAddresses=true|")
elif answer.lower() == "n":
print("You requested deletion to be stopped")
else:
print("Invalid Entry")
# logout of BAM
client.service.logout()
# return the records from function
示例11: gethostrecordwithhint
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def gethostrecordwithhint(bam_url, login_user, login_password, host_record_name):
"""get the host record FQDN and return the entity details
"""
records = ""
try:
# api session
client = Client(bam_url)
# login
client.service.login(login_user, login_password)
# get the host record details
records = client.service.getHostRecordsByHint(
0,
10,
"hint="+host_record_name+"|"
)
# logout of BAM
client.service.logout()
except zeep.exceptions.Fault as e:
print(e.message)
logging.exception(e)
sys.exit(1)
# return the records from function
return records
示例12: test_module
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def test_module(client: Client, saved_report_id: int):
"""
Performs basic get request to get item samples
"""
helpers.serialize_object(client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=parse_date_range('1 year')[0]
))
demisto.results('ok')
示例13: get_incident_details_command
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def get_incident_details_command(client: Client, args: dict) -> Tuple[str, dict, dict]:
incident_id: str = args.get('incident_id', '')
raw_incident: list = client.service.incidentDetail(
incidentId=incident_id,
includeHistory=True,
includeViolations=True
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incident and isinstance(raw_incident, list):
serialized_incident = helpers.serialize_object(raw_incident[0])
raw_response = json.loads(json.dumps(serialized_incident, default=datetime_to_iso_format))
incident_details: dict = get_incident_details(raw_response, args)
raw_headers = ['ID', 'CreationDate', 'DetectionDate', 'Severity', 'Status', 'MessageSourceType',
'MessageType', 'Policy Name']
headers = ['ID', 'Creation Date', 'Detection Date', 'Severity', 'Status', 'DLP Module',
'DLP Module subtype', 'Policy Name']
outputs: dict = {}
for raw_header in raw_headers:
if raw_header == 'Policy Name':
outputs['Policy Name'] = incident_details.get('Policy', {}).get('Name')
else:
outputs[headers[raw_headers.index(raw_header)]] = incident_details.get(raw_header)
human_readable = tableToMarkdown(f'Symantec DLP incident {incident_id} details', outputs, headers=headers,
removeNull=True)
entry_context = {'SymantecDLP.Incident(val.ID && val.ID === obj.ID)': incident_details}
else:
human_readable = 'No incident found.'
return human_readable, entry_context, raw_response
示例14: list_incidents_command
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def list_incidents_command(client: Client, args: dict, saved_report_id: str) -> Tuple[str, dict, dict]:
if not saved_report_id:
raise ValueError('Missing saved report ID. Configure it in the integration instance settings.')
creation_date = parse_date_range(args.get('creation_date', '1 day'))[0]
raw_incidents = client.service.incidentList(
savedReportId=saved_report_id,
incidentCreationDateLaterThan=creation_date
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incidents:
serialized_incidents: dict = helpers.serialize_object(raw_incidents)
incidents_ids_list = serialized_incidents.get('incidentId')
if incidents_ids_list:
raw_response = serialized_incidents
incidents = [{'ID': str(incident_id)} for incident_id in incidents_ids_list]
human_readable = tableToMarkdown('Symantec DLP incidents', incidents, removeNull=True)
entry_context = {'SymantecDLP.Incident(val.ID && val.ID == obj.ID)': incidents}
else:
human_readable = 'No incidents found.'
else:
human_readable = 'No incidents found.'
return human_readable, entry_context, raw_response
示例15: update_incident_command
# 需要导入模块: import zeep [as 别名]
# 或者: from zeep import Client [as 别名]
def update_incident_command(client: Client, args: dict) -> Tuple[str, dict, dict]:
incident_id: str = args.get('incident_id', '')
incident_attributes: dict = get_incident_attributes(args)
raw_incidents_update_response = client.service.updateIncidents(
updateBatch={
'batchId': '_' + str(uuid.uuid1()),
'incidentId': incident_id,
'incidentAttributes': incident_attributes
}
)
human_readable: str
entry_context: dict = {}
raw_response: dict = {}
if raw_incidents_update_response and isinstance(raw_incidents_update_response, list):
incidents_update_response = helpers.serialize_object(raw_incidents_update_response[0])
headers: list = ['Batch ID', 'Inaccessible Incident Long ID', 'Inaccessible Incident ID', 'Status Code']
outputs = {
'Batch ID': incidents_update_response.get('batchId'),
'Inaccessible Incident Long ID': incidents_update_response.get('InaccessibleIncidentLongId'),
'Inaccessible Incident ID': incidents_update_response.get('InaccessibleIncidentId'),
'Status Code': incidents_update_response.get('statusCode')
}
if outputs.get('Status Code') == 'VALIDATION_ERROR':
raise DemistoException('Update was not successful. ADVICE: If status or custom attribute were changed,'
' check that they are configured in Symantec DLP.')
human_readable = tableToMarkdown(f'Symantec DLP incidents {incident_id} update', outputs, headers=headers,
removeNull=True)
else:
human_readable = 'Update was not successful'
return human_readable, entry_context, raw_response