byteplus-sdk 1.0.62__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.
- byteplus_sdk/ApiInfo.py +13 -0
- byteplus_sdk/Credentials.py +15 -0
- byteplus_sdk/Policy.py +91 -0
- byteplus_sdk/ServiceInfo.py +11 -0
- byteplus_sdk/ServiceInfoHttps.py +11 -0
- byteplus_sdk/__init__.py +2 -0
- byteplus_sdk/auth/MetaData.py +29 -0
- byteplus_sdk/auth/SignerV4.py +145 -0
- byteplus_sdk/auth/__init__.py +0 -0
- byteplus_sdk/base/Request.py +51 -0
- byteplus_sdk/base/Service.py +227 -0
- byteplus_sdk/base/__init__.py +0 -0
- byteplus_sdk/base/models/__init__.py +0 -0
- byteplus_sdk/base/models/base/__init__.py +0 -0
- byteplus_sdk/base/models/base/base_pb2.py +46 -0
- byteplus_sdk/cdn/__init__.py +0 -0
- byteplus_sdk/cdn/service.py +1203 -0
- byteplus_sdk/const/Const.py +66 -0
- byteplus_sdk/const/__init__.py +0 -0
- byteplus_sdk/example/__init__.py +1 -0
- byteplus_sdk/example/cdn/__init__.py +3 -0
- byteplus_sdk/example/cdn/add_cdn_certificate.py +27 -0
- byteplus_sdk/example/cdn/add_cdn_domain.py +35 -0
- byteplus_sdk/example/cdn/add_template_domain.py +26 -0
- byteplus_sdk/example/cdn/create_cipher_template.py +25 -0
- byteplus_sdk/example/cdn/create_rule_engine_template.py +161 -0
- byteplus_sdk/example/cdn/create_service_template.py +41 -0
- byteplus_sdk/example/cdn/delete_cdn_domain.py +19 -0
- byteplus_sdk/example/cdn/delete_template.py +20 -0
- byteplus_sdk/example/cdn/describe_accounting_data.py +24 -0
- byteplus_sdk/example/cdn/describe_cdn_access_log.py +23 -0
- byteplus_sdk/example/cdn/describe_cdn_config.py +19 -0
- byteplus_sdk/example/cdn/describe_cdn_data.py +29 -0
- byteplus_sdk/example/cdn/describe_cdn_data_detail.py +25 -0
- byteplus_sdk/example/cdn/describe_cdn_detail.py +26 -0
- byteplus_sdk/example/cdn/describe_cdn_origin_data.py +24 -0
- byteplus_sdk/example/cdn/describe_cdn_region_and_isp.py +19 -0
- byteplus_sdk/example/cdn/describe_cdn_service.py +15 -0
- byteplus_sdk/example/cdn/describe_cdn_upper_ip.py +19 -0
- byteplus_sdk/example/cdn/describe_cipher_template.py +20 -0
- byteplus_sdk/example/cdn/describe_content_block_tasks.py +23 -0
- byteplus_sdk/example/cdn/describe_content_quota.py +14 -0
- byteplus_sdk/example/cdn/describe_content_tasks.py +21 -0
- byteplus_sdk/example/cdn/describe_edge_nrt_data_summary.py +23 -0
- byteplus_sdk/example/cdn/describe_edge_statistical_data.py +24 -0
- byteplus_sdk/example/cdn/describe_edge_top_nrt_data.py +25 -0
- byteplus_sdk/example/cdn/describe_edge_top_statistical_data.py +25 -0
- byteplus_sdk/example/cdn/describe_edge_top_status_code.py +22 -0
- byteplus_sdk/example/cdn/describe_ip_info.py +19 -0
- byteplus_sdk/example/cdn/describe_ip_list_info.py +20 -0
- byteplus_sdk/example/cdn/describe_origin_nrt_data_summary.py +23 -0
- byteplus_sdk/example/cdn/describe_origin_top_nrt_data.py +24 -0
- byteplus_sdk/example/cdn/describe_origin_top_status_code.py +22 -0
- byteplus_sdk/example/cdn/describe_rule_engine_template.py +23 -0
- byteplus_sdk/example/cdn/describe_service_template.py +20 -0
- byteplus_sdk/example/cdn/describe_template_domains.py +22 -0
- byteplus_sdk/example/cdn/describe_templates.py +30 -0
- byteplus_sdk/example/cdn/duplicate_template.py +23 -0
- byteplus_sdk/example/cdn/list_cdn_cert_info.py +19 -0
- byteplus_sdk/example/cdn/list_cdn_domains.py +19 -0
- byteplus_sdk/example/cdn/list_cert_info.py +20 -0
- byteplus_sdk/example/cdn/lock_template.py +20 -0
- byteplus_sdk/example/cdn/release_template.py +23 -0
- byteplus_sdk/example/cdn/start_cdn_domain.py +19 -0
- byteplus_sdk/example/cdn/stop_cdn_domain.py +19 -0
- byteplus_sdk/example/cdn/submit_block_task.py +18 -0
- byteplus_sdk/example/cdn/submit_preload_task.py +18 -0
- byteplus_sdk/example/cdn/submit_refresh_task.py +19 -0
- byteplus_sdk/example/cdn/submit_unblock_task.py +18 -0
- byteplus_sdk/example/cdn/update_cdn_config.py +34 -0
- byteplus_sdk/example/cdn/update_cipher_template.py +48 -0
- byteplus_sdk/example/cdn/update_rule_engine_template.py +62 -0
- byteplus_sdk/example/cdn/update_service_template.py +42 -0
- byteplus_sdk/example/cdn/update_template_domain.py +29 -0
- byteplus_sdk/example/live/__init__.py +0 -0
- byteplus_sdk/example/rtc/RtcService.py +53 -0
- byteplus_sdk/example/rtc/__init__.py +0 -0
- byteplus_sdk/example/rtc/example_get_record_task.py +25 -0
- byteplus_sdk/example/rtc/example_start_record.py +86 -0
- byteplus_sdk/example/visual/__init__.py +0 -0
- byteplus_sdk/example/visual/cv_cancel_task.py +19 -0
- byteplus_sdk/example/visual/cv_get_result.py +19 -0
- byteplus_sdk/example/visual/cv_process.py +20 -0
- byteplus_sdk/example/visual/cv_submit_task.py +19 -0
- byteplus_sdk/example/visual/cv_sync2async_get_result.py +20 -0
- byteplus_sdk/example/visual/cv_sync2async_submit_task.py +20 -0
- byteplus_sdk/example/visual/example_common.py +32 -0
- byteplus_sdk/iam/IamService.py +42 -0
- byteplus_sdk/iam/__init__.py +0 -0
- byteplus_sdk/live/LiveService.py +571 -0
- byteplus_sdk/live/__init__.py +1 -0
- byteplus_sdk/live/v20200801/__init__.py +1 -0
- byteplus_sdk/live/v20200801/live_config.py +18 -0
- byteplus_sdk/live/v20200801/live_service.py +12 -0
- byteplus_sdk/live/v20200801/live_trait.py +62 -0
- byteplus_sdk/live/v20230101/__init__.py +1 -0
- byteplus_sdk/live/v20230101/live_config.py +171 -0
- byteplus_sdk/live/v20230101/live_service.py +12 -0
- byteplus_sdk/live/v20230101/live_trait.py +1133 -0
- byteplus_sdk/sms/SmsService.py +158 -0
- byteplus_sdk/sms/__init__.py +0 -0
- byteplus_sdk/util/Functions.py +37 -0
- byteplus_sdk/util/Util.py +116 -0
- byteplus_sdk/util/__init__.py +0 -0
- byteplus_sdk/visual/VisualService.py +142 -0
- byteplus_sdk/visual/__init__.py +0 -0
- byteplus_sdk/vod/VodService.py +2941 -0
- byteplus_sdk/vod/VodServiceConfig.py +134 -0
- byteplus_sdk/vod/__init__.py +0 -0
- byteplus_sdk/vod/models/__init__.py +0 -0
- byteplus_sdk/vod/models/business/__init__.py +0 -0
- byteplus_sdk/vod/models/business/vod_apps_manage_pb2.py +35 -0
- byteplus_sdk/vod/models/business/vod_callback_pb2.py +32 -0
- byteplus_sdk/vod/models/business/vod_cdn_pb2.py +434 -0
- byteplus_sdk/vod/models/business/vod_common_pb2.py +342 -0
- byteplus_sdk/vod/models/business/vod_edit_pb2.py +55 -0
- byteplus_sdk/vod/models/business/vod_measure_pb2.py +395 -0
- byteplus_sdk/vod/models/business/vod_media_pb2.py +547 -0
- byteplus_sdk/vod/models/business/vod_play_pb2.py +95 -0
- byteplus_sdk/vod/models/business/vod_project_pb2.py +45 -0
- byteplus_sdk/vod/models/business/vod_quality_platform_pb2.py +46 -0
- byteplus_sdk/vod/models/business/vod_smart_strategy_pb2.py +53 -0
- byteplus_sdk/vod/models/business/vod_space_pb2.py +63 -0
- byteplus_sdk/vod/models/business/vod_upload_pb2.py +344 -0
- byteplus_sdk/vod/models/business/vod_workflow_pb2.py +389 -0
- byteplus_sdk/vod/models/request/__init__.py +0 -0
- byteplus_sdk/vod/models/request/request_vod_pb2.py +1250 -0
- byteplus_sdk/vod/models/response/__init__.py +0 -0
- byteplus_sdk/vod/models/response/response_vod_pb2.py +1199 -0
- byteplus_sdk-1.0.62.dist-info/METADATA +24 -0
- byteplus_sdk-1.0.62.dist-info/RECORD +134 -0
- byteplus_sdk-1.0.62.dist-info/WHEEL +5 -0
- byteplus_sdk-1.0.62.dist-info/licenses/LICENSE +201 -0
- byteplus_sdk-1.0.62.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../")
|
|
6
|
+
|
|
7
|
+
from byteplus_sdk.example.cdn import ak, sk
|
|
8
|
+
from byteplus_sdk.cdn.service import CDNService
|
|
9
|
+
|
|
10
|
+
if __name__ == '__main__':
|
|
11
|
+
svc = CDNService()
|
|
12
|
+
svc.set_ak(ak)
|
|
13
|
+
svc.set_sk(sk)
|
|
14
|
+
|
|
15
|
+
body = {
|
|
16
|
+
'Domain': 'example.com',
|
|
17
|
+
'Origin': [
|
|
18
|
+
{
|
|
19
|
+
'OriginAction': {
|
|
20
|
+
'OriginLines': [{
|
|
21
|
+
'OriginType': 'primary',
|
|
22
|
+
'InstanceType': 'domain',
|
|
23
|
+
'Address': 'new-origin.com',
|
|
24
|
+
'HttpPort': '80',
|
|
25
|
+
'HttpsPort': '443',
|
|
26
|
+
'Weight': '100'
|
|
27
|
+
}]
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
],
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
resp = svc.update_cdn_config(body)
|
|
34
|
+
print(resp)
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../")
|
|
6
|
+
|
|
7
|
+
from byteplus_sdk.example.cdn import ak, sk
|
|
8
|
+
from byteplus_sdk.cdn.service import CDNService
|
|
9
|
+
|
|
10
|
+
if __name__ == '__main__':
|
|
11
|
+
svc = CDNService()
|
|
12
|
+
svc.set_ak(ak)
|
|
13
|
+
svc.set_sk(sk)
|
|
14
|
+
|
|
15
|
+
body = {
|
|
16
|
+
"Title": "example",
|
|
17
|
+
"Message": "example",
|
|
18
|
+
"Project": "default",
|
|
19
|
+
"Quic": {
|
|
20
|
+
"Switch": False
|
|
21
|
+
},
|
|
22
|
+
"HTTPS": {
|
|
23
|
+
"HTTP2": False,
|
|
24
|
+
"OCSP": False,
|
|
25
|
+
"TlsVersion": [
|
|
26
|
+
"tlsv1.1",
|
|
27
|
+
"tlsv1.2",
|
|
28
|
+
"tlsv1.3"
|
|
29
|
+
],
|
|
30
|
+
"Hsts": {
|
|
31
|
+
"Switch": True,
|
|
32
|
+
"Ttl": 0,
|
|
33
|
+
"Subdomain": "exclude"
|
|
34
|
+
},
|
|
35
|
+
"ForcedRedirect": {
|
|
36
|
+
"EnableForcedRedirect": False,
|
|
37
|
+
"StatusCode": ""
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
"HttpForcedRedirect": {
|
|
41
|
+
"EnableForcedRedirect": False,
|
|
42
|
+
"StatusCode": ""
|
|
43
|
+
},
|
|
44
|
+
"TemplateId": "tpl-example"
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
resp = svc.update_cipher_template(body)
|
|
48
|
+
print(resp)
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../")
|
|
6
|
+
|
|
7
|
+
from byteplus_sdk.example.cdn import ak, sk
|
|
8
|
+
from byteplus_sdk.cdn.service import CDNService
|
|
9
|
+
|
|
10
|
+
# pip3 install cdn_rule_engine_sdk
|
|
11
|
+
from cdn_rule_engine_sdk.rule_engine.Const import Const
|
|
12
|
+
from cdn_rule_engine_sdk.rule_engine.Rule import Rule, Condition, Action
|
|
13
|
+
|
|
14
|
+
def example():
|
|
15
|
+
cdn_service = CDNService()
|
|
16
|
+
cdn_service.set_ak(ak)
|
|
17
|
+
cdn_service.set_sk(sk)
|
|
18
|
+
|
|
19
|
+
rule = Rule()
|
|
20
|
+
rule.desc = "example"
|
|
21
|
+
rule.if_block.condition = Condition({
|
|
22
|
+
"IsGroup": False,
|
|
23
|
+
"Connective": Const.ConnectiveAnd,
|
|
24
|
+
"Condition": {
|
|
25
|
+
"Object": Const.ConditionAlways,
|
|
26
|
+
}
|
|
27
|
+
})
|
|
28
|
+
rule.if_block.actions.append(Action({
|
|
29
|
+
"Action": Const.ActionCacheTime,
|
|
30
|
+
"Groups": [{
|
|
31
|
+
"Dimension": Const.ActionCacheTime,
|
|
32
|
+
"GroupParameters": [{
|
|
33
|
+
"Parameters": [
|
|
34
|
+
{
|
|
35
|
+
"Name": "ttl",
|
|
36
|
+
"Values": ["0"]
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"Name": "ttl_unit",
|
|
40
|
+
"Values": ["sec"]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"Name": "cache_policy",
|
|
44
|
+
"Values": [Const.CacheDefault]
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"Name": "force_cache",
|
|
48
|
+
"Values": ["true"]
|
|
49
|
+
}
|
|
50
|
+
]
|
|
51
|
+
}]
|
|
52
|
+
}]
|
|
53
|
+
}))
|
|
54
|
+
rsp = cdn_service.update_rule_engine_template({
|
|
55
|
+
"TemplateId": "tpl-example",
|
|
56
|
+
"TemplateVersion": "draft",
|
|
57
|
+
"Rule": rule.encode_to_string()
|
|
58
|
+
})
|
|
59
|
+
print(rsp)
|
|
60
|
+
|
|
61
|
+
if __name__ == '__main__':
|
|
62
|
+
example()
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../")
|
|
6
|
+
|
|
7
|
+
from byteplus_sdk.example.cdn import ak, sk
|
|
8
|
+
from byteplus_sdk.cdn.service import CDNService
|
|
9
|
+
|
|
10
|
+
if __name__ == '__main__':
|
|
11
|
+
svc = CDNService()
|
|
12
|
+
svc.set_ak(ak)
|
|
13
|
+
svc.set_sk(sk)
|
|
14
|
+
|
|
15
|
+
body = {
|
|
16
|
+
"Title": "example",
|
|
17
|
+
"Message": "example",
|
|
18
|
+
"Project": "default",
|
|
19
|
+
"OriginProtocol": "http",
|
|
20
|
+
"OriginHost": "",
|
|
21
|
+
"Origin": [
|
|
22
|
+
{
|
|
23
|
+
"OriginAction": {
|
|
24
|
+
"OriginLines": [
|
|
25
|
+
{
|
|
26
|
+
"Address": "example.com",
|
|
27
|
+
"HttpPort": "80",
|
|
28
|
+
"HttpsPort": "443",
|
|
29
|
+
"InstanceType": "domain",
|
|
30
|
+
"OriginHost": "",
|
|
31
|
+
"OriginType": "primary",
|
|
32
|
+
"Weight": "1"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
],
|
|
38
|
+
"TemplateId": "tpl-example"
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
resp = svc.update_service_template(body)
|
|
42
|
+
print(resp)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
sys.path.append(os.path.dirname(os.path.realpath(__file__)) + "/../../../")
|
|
6
|
+
|
|
7
|
+
from byteplus_sdk.example.cdn import ak, sk
|
|
8
|
+
from byteplus_sdk.cdn.service import CDNService
|
|
9
|
+
|
|
10
|
+
if __name__ == '__main__':
|
|
11
|
+
svc = CDNService()
|
|
12
|
+
svc.set_ak(ak)
|
|
13
|
+
svc.set_sk(sk)
|
|
14
|
+
|
|
15
|
+
body = {
|
|
16
|
+
"ServiceRegion": "global",
|
|
17
|
+
"Project": "default",
|
|
18
|
+
"ServiceTemplateId": "tpl-example",
|
|
19
|
+
"SparrowSwitch": "off",
|
|
20
|
+
"CertId": "cert-example",
|
|
21
|
+
"CipherTemplateId": "tpl-example",
|
|
22
|
+
"HTTPSSwitch": "on",
|
|
23
|
+
"Domains": [
|
|
24
|
+
"example.com"
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
resp = svc.update_template_domain(body)
|
|
29
|
+
print(resp)
|
|
File without changes
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
import json
|
|
3
|
+
import threading
|
|
4
|
+
|
|
5
|
+
from byteplus_sdk.ApiInfo import ApiInfo
|
|
6
|
+
from byteplus_sdk.Credentials import Credentials
|
|
7
|
+
from byteplus_sdk.base.Service import Service
|
|
8
|
+
from byteplus_sdk.ServiceInfo import ServiceInfo
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class RtcService(Service):
|
|
12
|
+
_instance_lock = threading.Lock()
|
|
13
|
+
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(RtcService, "_instance"):
|
|
16
|
+
with RtcService._instance_lock:
|
|
17
|
+
if not hasattr(RtcService, "_instance"):
|
|
18
|
+
RtcService._instance = object.__new__(cls)
|
|
19
|
+
return RtcService._instance
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
self.service_info = RtcService.get_service_info()
|
|
23
|
+
self.api_info = RtcService.get_api_info()
|
|
24
|
+
super(RtcService, self).__init__(self.service_info, self.api_info)
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def get_service_info():
|
|
28
|
+
service_info = ServiceInfo("open.byteplusapi.com", {'Accept': 'application/json'},
|
|
29
|
+
Credentials('', '', 'rtc', 'ap-singapore-1'), 5, 5)
|
|
30
|
+
return service_info
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def get_api_info():
|
|
34
|
+
api_info = {
|
|
35
|
+
"StartRecord": ApiInfo("POST", "/", {"Action": "StartRecord", "Version": "2022-06-01"}, {}, {}),
|
|
36
|
+
"GetRecordTask": ApiInfo("GET", "/", {"Action": "GetRecordTask", "Version": "2022-06-01"}, {}, {}),
|
|
37
|
+
}
|
|
38
|
+
return api_info
|
|
39
|
+
|
|
40
|
+
def start_record(self, body):
|
|
41
|
+
res = self.json("StartRecord", {}, body)
|
|
42
|
+
if res == '':
|
|
43
|
+
raise Exception("StartRecord: empty response")
|
|
44
|
+
res_json = json.loads(res)
|
|
45
|
+
return res_json
|
|
46
|
+
|
|
47
|
+
def get_record_task(self, params):
|
|
48
|
+
res = self.get("GetRecordTask", params)
|
|
49
|
+
if res == '':
|
|
50
|
+
raise Exception("GetRecordTask: empty response")
|
|
51
|
+
res_json = json.loads(res)
|
|
52
|
+
return res_json
|
|
53
|
+
|
|
File without changes
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk.example.rtc.RtcService import RtcService
|
|
5
|
+
|
|
6
|
+
if __name__ == '__main__':
|
|
7
|
+
# Using your own AK and SK
|
|
8
|
+
AK = 'Your_AK'
|
|
9
|
+
SK = 'Your_SK'
|
|
10
|
+
|
|
11
|
+
# Firstly, init an RTCService Class
|
|
12
|
+
rtc_service = RtcService()
|
|
13
|
+
|
|
14
|
+
# Then, Set your AK and SK
|
|
15
|
+
rtc_service.set_ak(AK)
|
|
16
|
+
rtc_service.set_sk(SK)
|
|
17
|
+
|
|
18
|
+
# You can using this API now ! Here are some Examples
|
|
19
|
+
params = dict()
|
|
20
|
+
params['AppId'] = 'Your_AppId'
|
|
21
|
+
params['RoomId'] = 'Your_RoomId'
|
|
22
|
+
params['TaskId'] = 'Your_TaskId'
|
|
23
|
+
|
|
24
|
+
resp = rtc_service.get_record_task(params)
|
|
25
|
+
print(resp)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
from byteplus_sdk.example.rtc.RtcService import RtcService
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def set_encode():
|
|
10
|
+
encode = dict()
|
|
11
|
+
encode['VideoWidth'] = 1920
|
|
12
|
+
encode['VideoHeight'] = 1080
|
|
13
|
+
encode['VideoFps'] = 15
|
|
14
|
+
encode['VideoBitrate'] = 4000
|
|
15
|
+
encode['VideoCodec'] = 0
|
|
16
|
+
encode['VideoGop'] = 4
|
|
17
|
+
encode['AudioCodec'] = 0
|
|
18
|
+
encode['AudioProfile'] = 0
|
|
19
|
+
encode['AudioBitrate'] = 64
|
|
20
|
+
encode['AudioSampleRate'] = 48000
|
|
21
|
+
encode['AudioChannels'] = 2
|
|
22
|
+
return encode
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def set_layout():
|
|
26
|
+
layout = dict()
|
|
27
|
+
layout['LayoutMode'] = 0
|
|
28
|
+
return layout
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def set_control():
|
|
32
|
+
control = dict()
|
|
33
|
+
control['MediaType'] = 0
|
|
34
|
+
control['FrameInterpolationMode'] = 0
|
|
35
|
+
control['MaxIdleTime'] = 180
|
|
36
|
+
control['MaxRecordTime'] = 0
|
|
37
|
+
return control
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def set_file_format_config():
|
|
41
|
+
config = dict()
|
|
42
|
+
config['FileFormat'] = ['MP4']
|
|
43
|
+
return config
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def set_storage_config():
|
|
47
|
+
config = dict()
|
|
48
|
+
config['Type'] = 1
|
|
49
|
+
config['VodConfig'] = set_vod_config()
|
|
50
|
+
return config
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def set_vod_config():
|
|
54
|
+
config = dict()
|
|
55
|
+
config['AccountId'] = 'Your_AccountId'
|
|
56
|
+
config['Space'] = "Your_Space"
|
|
57
|
+
return config
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
if __name__ == '__main__':
|
|
61
|
+
# using your own AK and SK
|
|
62
|
+
AK = 'Your_AK'
|
|
63
|
+
SK = 'Your_SK'
|
|
64
|
+
|
|
65
|
+
# Firstly , init an RTCService Class
|
|
66
|
+
rtc_service = RtcService()
|
|
67
|
+
|
|
68
|
+
# Then , Set your AK and SK
|
|
69
|
+
rtc_service.set_ak(AK)
|
|
70
|
+
rtc_service.set_sk(SK)
|
|
71
|
+
|
|
72
|
+
# You can using this API now ! Here are some Examples
|
|
73
|
+
body = dict()
|
|
74
|
+
body['AppId'] = 'Your_AppId'
|
|
75
|
+
body['BusinessId'] = 'Your_BusinessId'
|
|
76
|
+
body['RoomId'] = 'Your_RoomId'
|
|
77
|
+
body['TaskId'] = 'Your_TaskId'
|
|
78
|
+
body['RecordMode'] = 0
|
|
79
|
+
body['Encode'] = set_encode()
|
|
80
|
+
body['Layout'] = set_layout()
|
|
81
|
+
body['Control'] = set_control()
|
|
82
|
+
body['FileFormatConfig'] = set_file_format_config()
|
|
83
|
+
body['StorageConfig'] = set_storage_config()
|
|
84
|
+
|
|
85
|
+
resp = rtc_service.start_record(body)
|
|
86
|
+
print(resp)
|
|
File without changes
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk import visual
|
|
5
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
6
|
+
|
|
7
|
+
if __name__ == '__main__':
|
|
8
|
+
visual_service = VisualService()
|
|
9
|
+
|
|
10
|
+
# call below method if you don't set ak and sk in $HOME/.volc/config
|
|
11
|
+
visual_service.set_ak('AK')
|
|
12
|
+
visual_service.set_sk('Sk')
|
|
13
|
+
|
|
14
|
+
form = {
|
|
15
|
+
"req_key": "xxx",
|
|
16
|
+
"task_id": "xxx"
|
|
17
|
+
}
|
|
18
|
+
resp = visual_service.cv_cancel_task(form)
|
|
19
|
+
print(resp)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk import visual
|
|
5
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
6
|
+
|
|
7
|
+
if __name__ == '__main__':
|
|
8
|
+
visual_service = VisualService()
|
|
9
|
+
|
|
10
|
+
# call below method if you don't set ak and sk in $HOME/.volc/config
|
|
11
|
+
visual_service.set_ak('AK')
|
|
12
|
+
visual_service.set_sk('Sk')
|
|
13
|
+
|
|
14
|
+
form = {
|
|
15
|
+
"req_key": "xxx",
|
|
16
|
+
"task_id": "xxx"
|
|
17
|
+
}
|
|
18
|
+
resp = visual_service.cv_get_result(form)
|
|
19
|
+
print(resp)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk import visual
|
|
5
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
6
|
+
|
|
7
|
+
if __name__ == '__main__':
|
|
8
|
+
visual_service = VisualService()
|
|
9
|
+
|
|
10
|
+
# call below method if you don't set ak and sk in $HOME/.volc/config
|
|
11
|
+
visual_service.set_ak('AK')
|
|
12
|
+
visual_service.set_sk('SK')
|
|
13
|
+
|
|
14
|
+
form = {
|
|
15
|
+
"req_key": "xxx",
|
|
16
|
+
# ...
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
resp = visual_service.cv_process(form)
|
|
20
|
+
print(resp)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk import visual
|
|
5
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
6
|
+
|
|
7
|
+
if __name__ == '__main__':
|
|
8
|
+
visual_service = VisualService()
|
|
9
|
+
|
|
10
|
+
# call below method if you don't set ak and sk in $HOME/.volc/config
|
|
11
|
+
visual_service.set_ak('AK')
|
|
12
|
+
visual_service.set_sk('SK')
|
|
13
|
+
|
|
14
|
+
form = {
|
|
15
|
+
"req_key": "xxx",
|
|
16
|
+
# ....
|
|
17
|
+
}
|
|
18
|
+
resp = visual_service.cv_submit_task( form)
|
|
19
|
+
print(resp)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk import visual
|
|
5
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
6
|
+
|
|
7
|
+
if __name__ == '__main__':
|
|
8
|
+
visual_service = VisualService()
|
|
9
|
+
|
|
10
|
+
# call below method if you don't set ak and sk in $HOME/.volc/config
|
|
11
|
+
visual_service.set_ak('AK')
|
|
12
|
+
visual_service.set_sk('SK')
|
|
13
|
+
|
|
14
|
+
form = {
|
|
15
|
+
"req_key": "xxx",
|
|
16
|
+
"task_id": "xxx",
|
|
17
|
+
"req_json": "{\"logo_info\":{\"add_logo\":true,\"position\":1, \"language\":1,\"opacity\":0.5}}"
|
|
18
|
+
}
|
|
19
|
+
resp = visual_service.cv_sync2async_get_result(form)
|
|
20
|
+
print(resp)
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk import visual
|
|
5
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
6
|
+
|
|
7
|
+
if __name__ == '__main__':
|
|
8
|
+
visual_service = VisualService()
|
|
9
|
+
|
|
10
|
+
# call below method if you don't set ak and sk in $HOME/.volc/config
|
|
11
|
+
visual_service.set_ak('AK')
|
|
12
|
+
visual_service.set_sk('SK')
|
|
13
|
+
|
|
14
|
+
form = {
|
|
15
|
+
"req_key": "xxx",
|
|
16
|
+
# ...
|
|
17
|
+
|
|
18
|
+
}
|
|
19
|
+
resp = visual_service.cv_sync2async_submit_task(form)
|
|
20
|
+
print(resp)
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
from __future__ import print_function
|
|
3
|
+
|
|
4
|
+
from byteplus_sdk.visual.VisualService import VisualService
|
|
5
|
+
|
|
6
|
+
if __name__ == '__main__':
|
|
7
|
+
visual_service = VisualService()
|
|
8
|
+
|
|
9
|
+
# call below method if you dont set ak and sk in $HOME/.volc/config
|
|
10
|
+
visual_service.set_ak('ak')
|
|
11
|
+
visual_service.set_sk('sk')
|
|
12
|
+
|
|
13
|
+
# below shows the sdk usage for all common apis,
|
|
14
|
+
# if you cannot find the needed one, please check other example files in the same dir
|
|
15
|
+
# or contact us for further help
|
|
16
|
+
form = dict()
|
|
17
|
+
with open("image.jpeg", "rb") as f:
|
|
18
|
+
import base64
|
|
19
|
+
image = f.read()
|
|
20
|
+
form["image_base64"] = base64.b64encode(image)
|
|
21
|
+
|
|
22
|
+
# comic portrait
|
|
23
|
+
# form["cartoon_type"] = "jpcartoon_head"
|
|
24
|
+
# form["rotation"] = 0 # this param is valid only when cartoon_type == jpcartoon_head
|
|
25
|
+
# resp = visual_service.comic_portrait(form)
|
|
26
|
+
|
|
27
|
+
# portrait fusion
|
|
28
|
+
# form["template_base64"] = "template_base64_str"
|
|
29
|
+
# form["action_id"] = "faceswap"
|
|
30
|
+
# resp = visual_service.portrait_fusion(form)
|
|
31
|
+
|
|
32
|
+
print(resp)
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# coding:utf-8
|
|
2
|
+
import json
|
|
3
|
+
import threading
|
|
4
|
+
|
|
5
|
+
from byteplus_sdk.ApiInfo import ApiInfo
|
|
6
|
+
from byteplus_sdk.Credentials import Credentials
|
|
7
|
+
from byteplus_sdk.base.Service import Service
|
|
8
|
+
from byteplus_sdk.ServiceInfo import ServiceInfo
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class IamService(Service):
|
|
12
|
+
_instance_lock = threading.Lock()
|
|
13
|
+
|
|
14
|
+
def __new__(cls, *args, **kwargs):
|
|
15
|
+
if not hasattr(IamService, "_instance"):
|
|
16
|
+
with IamService._instance_lock:
|
|
17
|
+
if not hasattr(IamService, "_instance"):
|
|
18
|
+
IamService._instance = object.__new__(cls)
|
|
19
|
+
return IamService._instance
|
|
20
|
+
|
|
21
|
+
def __init__(self):
|
|
22
|
+
self.service_info = IamService.get_service_info()
|
|
23
|
+
self.api_info = IamService.get_api_info()
|
|
24
|
+
super(IamService, self).__init__(self.service_info, self.api_info)
|
|
25
|
+
|
|
26
|
+
@staticmethod
|
|
27
|
+
def get_service_info():
|
|
28
|
+
service_info = ServiceInfo("open.byteplusapi.com", {'Accept': 'application/json'},
|
|
29
|
+
Credentials('', '', 'iam', 'ap-singapore-1'), 5, 5)
|
|
30
|
+
return service_info
|
|
31
|
+
|
|
32
|
+
@staticmethod
|
|
33
|
+
def get_api_info():
|
|
34
|
+
api_info = {"ListUsers": ApiInfo("GET", "/", {"Action": "ListUsers", "Version": "2018-01-01"}, {}, {})}
|
|
35
|
+
return api_info
|
|
36
|
+
|
|
37
|
+
def list_users(self, params):
|
|
38
|
+
res = self.get("ListUsers", params)
|
|
39
|
+
if res == '':
|
|
40
|
+
raise Exception("empty response")
|
|
41
|
+
res_json = json.loads(res)
|
|
42
|
+
return res_json
|
|
File without changes
|