API General methods¶
The utils function of the rayvision api.
-
rayvision_api.utils.
append_to_task
(additional_info, task_path, cover=True)¶ Add new field information in task_info.
Parameters:
-
rayvision_api.utils.
append_to_upload
(files_paths, upload_path)¶ Add the asset information you need to upload to upload_info.
Parameters:
-
rayvision_api.utils.
assemble_api_url
(domain, operators, protocol='https')¶ Assemble the requests api url.
-
rayvision_api.utils.
check_and_read
(json_path)¶
-
rayvision_api.utils.
check_upload_file
(file_path, upload_info)¶ Check that the file is already in the upload list.
Parameters: Returns: bool.
-
rayvision_api.utils.
convert_path
(path)¶ Convert to the path the server will accept.
Parameters: path (str) – Local file path. e.g.:
”D:/work/render/19183793/max/d/Work/c05/112132P-embery.jpg”Returns: - Path to the server.
- e.g.:
- ”/D/work/render/19183793/max/d/Work/c05/112132P-embery.jpg”
Return type: str
-
rayvision_api.utils.
exists_or_create
(folder)¶
-
rayvision_api.utils.
formatted_headers
(headers)¶ Please formatted dictionary.
Possible data types in the dictionary: numbers.Number, str, bytes, list, dict, None (json’s key can only be string, json’s value may be number, string, logical value, array, object, null).
Parameters: headers (dict) – The headers of the
Post
. e.g.:- {
- “taksId”: “2”,
“renderEnvs”: [
- {
- “envId”: 1,
- ”pluginIds”: [2, 3, 4]
}, {
- ”envId”: 3,
- ”pluginIds”: [7, 8, 10]
}
]
Returns: Handled request header. Return type: dict
-
rayvision_api.utils.
generate_headers_body_str
(domain_name, api_url, header, body)¶ Generate formatted strings.
Based on header and body for generating signatures (signature and Content-Type do not participate in signatures).
Format is Request Method + Domain Name + API URI + Request String.
Parameters: - domain_name (str) – Domain name.
- api_url (str) – Requested path.
- header (dict) –
Request header. e.g.:
- {
- ‘accessId’: ‘xxx’, ‘channel’: ‘4’, ‘platform’: ‘2’, ‘UTCTimestamp’: ‘32166266’, ‘nonce’: ‘1465’, ‘signature’: ‘’, ‘version’: ‘1.0.0’, ‘Content-Type’: ‘application/json’,
}
- e.g.:
- {
- ‘accessId’: ‘xxx’, ‘channel’: ‘4’, ‘platform’: ‘2’, ‘UTCTimestamp’: ‘32166266’, ‘nonce’: ‘1465’, ‘signature’: ‘’, ‘version’: ‘1.0.0’, ‘Content-Type’: ‘application/json’
}
- body (dict) – Request body.
Returns: Stitched string.
Return type:
-
rayvision_api.utils.
generate_nonce
()¶ Generate random Numbers for verification.
-
rayvision_api.utils.
generate_signature
(key, msg)¶ Generate a signature string.
First use the sha256 algorithm to calculate the summary of the msg hashed key and then use the base64 algorithm to get the signature string.
Parameters: Returns: Decoded string.
Return type:
-
rayvision_api.utils.
generate_timestamp
()¶ str: The timestamp.
-
rayvision_api.utils.
get_os
()¶ Get system name.
Returns: - The system/OS name.
- e.g.:
Linux
orWindows
.
Return type: str
-
rayvision_api.utils.
headers_body_sort
(header, body)¶ Generate a new processed dictionary.
The http request header and request parameters are sorted in ascending order by the lexicographic order (ASCII) of the parameter names.
Parameters: Returns: - Ordered dictionary object after request header and
request parameters are sorted.
Return type:
-
rayvision_api.utils.
hump2underline
(hump_str)¶ Convert the hump name to a snake shape.
Parameters: hump_str (str) – The name to be converted. Returns: Convert to a snake-like name. Return type: str
-
rayvision_api.utils.
json_load
(json_path, encoding='utf-8')¶ Load the data from the json file.
Parameters: Returns: - Data in the json file.
- e.g.:
- {
“task_info”
}
Return type:
-
rayvision_api.utils.
json_save
(json_path, data, encoding='utf-8', ensure_ascii=True)¶ Will save to the json file according to the specified encoded data.
Parameters:
-
rayvision_api.utils.
to_bytes
(string)¶ Convert string to bytes type.