-
Notifications
You must be signed in to change notification settings - Fork 262
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DP-5290 python-sdk/cdn: 查询域名带宽,支持type参数 #456
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,9 +5,17 @@ | |
|
||
from qiniu.compat import is_py2 | ||
from qiniu.compat import is_py3 | ||
from enum import Enum | ||
|
||
import hashlib | ||
|
||
class DataType(Enum): | ||
BANDWIDTH = 'bandwidth' | ||
X302BANDWIDTH = '302bandwidth' | ||
X302MBANDWIDTH = '302mbandwidth' | ||
FLOW = 'flow' | ||
X302FLOW = '302flow' | ||
X302MFLOW = '302mflow' | ||
|
||
def urlencode(str): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing function or method docstring (missing-function-docstring) Detailslint 解释
错误用法def calculate_area(width, height):
return width * height 正确用法
def calculate_area(width, height):
"""
计算矩形的面积
参数:
width (int): 矩形的宽度
height (int): 矩形的高度
返回:
int: 矩形的面积
"""
return width * height
def calculate_area(width, height):
# 计算矩形的面积
return width * height
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Redefining built-in 'str' (redefined-builtin) Detailslint 解释
错误用法package main
import "fmt"
func main() {
str := "Hello, World!" // 正确使用内置的 str 类型
fmt.Println(str)
str := "Another string" // 重新定义内置的 str 变量,导致命名冲突
fmt.Println(str)
} 正确用法package main
import "fmt"
func main() {
myString := "Hello, World!" // 使用自定义变量名避免命名冲突
fmt.Println(myString)
anotherString := "Another string" // 使用另一个自定义变量名
fmt.Println(anotherString)
}
|
||
if is_py2: | ||
|
@@ -60,7 +68,7 @@ def refresh_urls_and_dirs(self, urls, dirs): | |
Returns: | ||
一个dict变量和一个ResponseInfo对象 | ||
参考代码 examples/cdn_manager.py | ||
""" | ||
""" | ||
req = {} | ||
if urls is not None and len(urls) > 0: | ||
req.update({"urls": urls}) | ||
|
@@ -89,7 +97,7 @@ def prefetch_urls(self, urls): | |
url = '{0}/v2/tune/prefetch'.format(self.server) | ||
return self.__post(url, body) | ||
|
||
def get_bandwidth_data(self, domains, start_date, end_date, granularity): | ||
def get_bandwidth_data(self, domains, start_date, end_date, granularity, data_type=None): | ||
""" | ||
查询带宽数据,文档 https://developer.qiniu.com/fusion/api/traffic-bandwidth | ||
|
||
|
@@ -98,6 +106,7 @@ def get_bandwidth_data(self, domains, start_date, end_date, granularity): | |
start_date: 起始日期 | ||
end_date: 结束日期 | ||
granularity: 数据间隔 | ||
data_type: 计量数据类型, see class DataType.XXXBANDWIDTH | ||
|
||
Returns: | ||
一个dict变量和一个ResponseInfo对象 | ||
|
@@ -108,12 +117,14 @@ def get_bandwidth_data(self, domains, start_date, end_date, granularity): | |
req.update({"startDate": start_date}) | ||
req.update({"endDate": end_date}) | ||
req.update({"granularity": granularity}) | ||
if data_type is not None: | ||
req.update({'type': data_type.value}) # should be one of 'bandwidth', '302bandwidth', '302mbandwidth' | ||
|
||
body = json.dumps(req) | ||
url = '{0}/v2/tune/bandwidth'.format(self.server) | ||
return self.__post(url, body) | ||
|
||
def get_flux_data(self, domains, start_date, end_date, granularity): | ||
def get_flux_data(self, domains, start_date, end_date, granularity, data_type=None): | ||
""" | ||
查询流量数据,文档 https://developer.qiniu.com/fusion/api/traffic-bandwidth | ||
|
||
|
@@ -122,6 +133,7 @@ def get_flux_data(self, domains, start_date, end_date, granularity): | |
start_date: 起始日期 | ||
end_date: 结束日期 | ||
granularity: 数据间隔 | ||
data_type: 计量数据类型, see class DataType.XXXFLOW | ||
|
||
Returns: | ||
一个dict变量和一个ResponseInfo对象 | ||
|
@@ -132,6 +144,8 @@ def get_flux_data(self, domains, start_date, end_date, granularity): | |
req.update({"startDate": start_date}) | ||
req.update({"endDate": end_date}) | ||
req.update({"granularity": granularity}) | ||
if data_type is not None: | ||
req.update({'type': data_type.value}) # should be one of 'flow', '302flow', '302mflow' | ||
|
||
body = json.dumps(req) | ||
url = '{0}/v2/tune/flux'.format(self.server) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing class docstring (missing-class-docstring)
Details
lint 解释
错误用法
正确用法