impl#
Agent implementation.
- class acore_soap_app.agent.impl.Base[source]#
Base class for
SOAPRequest
andSOAPResponse
.
- class acore_soap_app.agent.impl.SOAPRequest(command: str, username: Optional[str] = None, password: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None)[source]#
SOAPRequest
is a dataclass to represent the SOAP XML request.Usage example
# this code only works in EC2 environment >>> request = SOAPRequest(command=".server info") >>> response = request.send() >>> response.to_json() { "body": "<?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:ns1="urn:AC"><SOAP-ENV:Body><ns1:executeCommandResponse><result>AzerothCore rev. 85311fa55983 2023-03-25 22:36:05 +0000 (master branch) (Unix, RelWithDebInfo, Static)
Connected players: 0. Characters in world: 0.
Connection peak: 0.
Server uptime: 54 minute(s) 3 second(s)
Update time diff: 10ms, average: 10ms.
</result></ns1:executeCommandResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>", "message": "AzerothCore rev. 85311fa55983 2023-03-25 22:36:05 +0000 (master branch) (Unix, RelWithDebInfo, Static)Connected players: 0. Characters in world: 0.Connection peak: 0.Server uptime: 54 minute(s) 3 second(s)Update time diff: 10ms, average: 10ms.", "succeeded": true }
- Parameters:
command – the command to execute.
username – the in game GM account username, default “admin”.
password – the in game GM account password, default “admin”.
host – wow world server host, default “localhost”.
port – wow world server SOAP port, default 7878.
More methods from base class:
- set_default(username: Optional[str], password: Optional[str])[source]#
Set default values for username and password if they are not set.
- send() SOAPResponse [source]#
Run soap command via HTTP request. This function “has to” be run on the game server and talk to the localhost. You should NEVER open SOAP port to public!
- classmethod batch_load(request_like: Union[str, List[str], SOAPRequest, List[SOAPRequest]], username: Optional[str] = None, password: Optional[str] = None, s3_client=None) List[SOAPRequest] [source]#
从各种形式的输入中加载
SOAPRequest
. 该方法总是返回一个列表.输入参数
request_like
代表着要运行的 GM 命令, 它可能是以下几种形式中的一种:- 如果是一个字符串:
- 如果是以 s3:// 开头, 那么就去 S3 读数据, 此时需要给定
s3_client
参数. 通常用于 payload 比较大的情况: - 如果读到的数据是单个字典, 那么就视为一个 SOAPRequest. - 如果读到的数据是一个列表, 那么就视为多个 SOAPRequest.
- 如果是以 s3:// 开头, 那么就去 S3 读数据, 此时需要给定
如果不是以 s3:// 开头, 那么就视为一个 GM command.
如果是一个字符串列表, 那么就视为多个 GM 命令.
它还可以是单个 SOAPRequest 或 SOAPRequest 列表.
这个参数最终都会被转换成 SOAPRequest 的列表.
- Parameters:
request_like – 上面已经说过了.
username – 默认的用户名, 只有当 request.username 为 None 的时候才会用到.
password – 默认的密码, 只有当 request.password 为 None 的时候才会用到.
s3_client – boto3.client(“s3”)
- class acore_soap_app.agent.impl.SOAPResponse(body: str, message: str, succeeded: bool)[source]#
SOAPResponse
is a dataclass to represent the SOAP XML response.Usage:
>>> res = SOAPResponse.parse( ... ''' ... <?xml version="1.0" encoding="UTF-8"?><SOAP-ENV:Envelope ... ...<result>Account created: test
</result>...</SOAP-ENV:Envelope> ... ''' ... ) >>> res.message Account created: test >>> res.succeeded True
- Parameters:
body – the raw SOAP XML response
message – if succeeded, it is the
<result>...</result>
part. if failed, it is the<faultstring>...</faultstring>
partsucceeded – a boolean flag to indicate whether the command is succeeded
More methods from base class:
- classmethod parse(body: str) SOAPResponse [source]#
Parse the SOAP XML response.