
Task and Billing Information Callback
Task and Billing Information Callback (POST)
If you have your own publicly accessible server, simply enter the address of the server that receives callback information in the Callback URL field in the Developer Center. We will send task status information and billing information to the specified address in real time.
If you do not have your own public server, you can create a service on your server and then enter its address in the Callback URL field in the Developer Center.
The following is an example of how to create a service:
from http.server import BaseHTTPRequestHandler, HTTPServer
class MyRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
print(post_data.decode('utf-8'))
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(b'Success')
def run():
host = "0.0.0.0"
port = 8888
server = HTTPServer((host, port), MyRequestHandler)
print(f"server: http://{host}:{port}")
server.serve_forever()
if __name__ == '__main__':
run()
Callback information can also be forwarded to other platforms, such as DingTalk or WeChat.
The following is an example of forwarding callback information to DingTalk:
import requests
import json
from http.server import BaseHTTPRequestHandler, HTTPServer
def send_dingtalk_notification(message):
url = 'https://oapi.dingtalk.com/robot/send?access_token=xxxxx' # Generated automatically when you create a bot in a DingTalk group.
data = {
"msgtype": "text",
"text": {
"content": "@mobile_number\n%s" % message
},
"at": {
"atMobiles": [
"mobile_number"
],
"isAtAll": False
}
}
headers = {'Content-Type': 'application/json'}
response = requests.post(url, headers=headers, data=json.dumps(data))
if response.status_code == 200:
print("Message sent successfully")
else:
print("Failed to send message")
class MyRequestHandler(BaseHTTPRequestHandler):
def do_POST(self):
content_length = int(self.headers['Content-Length'])
post_data = self.rfile.read(content_length)
send_dingtalk_notification(post_data.decode('utf-8'))
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
self.wfile.write(b'Success')
def run():
host = "0.0.0.0"
port = 8888
server = HTTPServer((host, port), MyRequestHandler)
print(f"server: http://{host}:{port}")
server.serve_forever()
if __name__ == '__main__':
run()
Detailed Callback Information
1. Task Information Callback
| Field | Type | Description |
|---|---|---|
platform |
str | Platform number |
action |
str | Task type; see the table below for details |
taskId |
int | Task ID |
parentId |
int | Parent task ID |
type |
int | Type |
bigTaskState |
str | Parent task status |
taskStartTime |
int | Parent task start time |
taskEndTime |
int | Parent task end time |
runningCount |
int | Number of running child tasks |
waitingCount |
int | Number of waiting child tasks |
successCount |
int | Number of successful child tasks |
failureCount |
int | Number of failed child tasks |
abortedCount |
int | Number of aborted child tasks |
timeoutCount |
int | Number of child tasks stopped due to timeout |
frameInfoId |
int | Primary key ID of the frame details record |
smallJobState |
str | Child task status |
jobStartTime |
int | Child task scheduling start time |
jobEndTime |
int | Child task scheduling end time |
renderType |
str | 0: GPU; 1: CPU |
renderStartTime |
int | Child task rendering start time |
renderEndTime |
int | Child task rendering end time |
Task Types (action)
| Task type | Description |
|---|---|
Analyze |
Analysis |
Pre |
Preprocessing |
RenderPhoton |
Photon rendering |
MergePhoton |
Photon merging |
PreRender |
Priority rendering task |
Render |
Standard rendering task |
2. Detailed Billing Information
| Field | Type | Description |
|---|---|---|
userId |
int | User ID |
mainUserId |
int | Main account ID |
userName |
str | Username |
feeAll |
int | Total amount charged |
taskId |
int | Task ID |
jobId |
int | Child task ID |
unitPrice |
int | Unit price |
feeTime |
int | Duration |
frameName |
str | Name of the charged frame |
startTime |
int | Start time |
endTime |
int | End time |
platform |
str | Platform number |
isMoreFrame |
bool | Whether multiple frames are rendered on one machine |
isMaxPrice |
str | Indicates whether the frame reached the price cap |
bigPic |
str | Full-size image path |
smallPic |
str | Thumbnail name |
frameRam |
int | Frame memory |
