Home
About
Blog
Products
Forum
Support
Contact
Sunbelt Computer Software
PL/B Language Development and Support
Home
About
Blog
Products
Forum
Support
Contact
Feishu-Bitable-Python-API/LIST_VIEWS.py at main · BlueSkyXN/Feishu-Bitable-Python-API · GitHub
Skip to content
Navigation Menu
Sign in
Appearance settings
Platform
AI CODE CREATION
GitHub Copilot
Write better code with AI
GitHub Copilot app
Direct agents from issue to merge
MCP Registry
Integrate external tools
DEVELOPER WORKFLOWS
Actions
Automate any workflow
Codespaces
Instant dev environments
Issues
Plan and track work
Code Review
Manage code changes
Code Quality
Enforce quality at merge
APPLICATION SECURITY
GitHub Advanced Security
Find and fix vulnerabilities
Code security
Secure your code as you build
Secret protection
Stop leaks before they start
EXPLORE
Why GitHub
Documentation
Blog
Changelog
Marketplace
View all features
Solutions
BY COMPANY SIZE
Enterprises
Small and medium teams
Startups
Nonprofits
BY USE CASE
App Modernization
DevSecOps
DevOps
CI/CD
View all use cases
BY INDUSTRY
Healthcare
Financial services
Manufacturing
Government
See all industries
View all solutions
Resources
EXPLORE BY TOPIC
AI
Software Development
DevOps
Security
View all topics
EXPLORE BY TYPE
Customer stories
Events & webinars
Ebooks & reports
Business insights
GitHub Skills
SUPPORT & SERVICES
Documentation
Customer support
Community forum
Trust center
Partners
View all resources
Open Source
COMMUNITY
GitHub Sponsors
Fund open source developers
PROGRAMS
Security Lab
Maintainer Community
GitHub Stars
Archive Program
REPOSITORIES
Topics
Trending
Collections
Enterprise
ENTERPRISE SOLUTIONS
Enterprise platform
AI-powered developer platform
AVAILABLE ADD-ONS
GitHub Advanced Security
Enterprise-grade security features
Copilot for Business
Enterprise-grade AI features
Premium Support
Enterprise-grade 24/7 support
Pricing
Search
/
Sign in
Sign up
Appearance settings
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
BlueSkyXN
Feishu-Bitable-Python-API
Repository navigation
Code
Issues
Pull requests
Discussions
Actions
Projects
Security and quality
Insights
More
items
Files
Expand file tree
main
Breadcrumbs
Feishu-Bitable-Python-API
/
LIST_VIEWS.py
Copy path
Blame
More file actions
Blame
More file actions
Latest commit
History
History
History
57 lines (45 loc) · 3.21 KB
main
Breadcrumbs
Feishu-Bitable-Python-API
/
LIST_VIEWS.py
Copy path
Top
File metadata and controls
Code
Blame
57 lines (45 loc) · 3.21 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import
requests
import
configparser
import
json
import
argparse
# 列出视图
# 此函数用于获取数据表的所有视图,接收五个可选参数
def
LIST_VIEWS
(
app_token
=
None
,
user_access_token
=
None
,
page_size
=
None
,
page_token
=
None
,
table_id
=
None
,
config_file
=
None
):
if
config_file
is
None
:
config_file
=
"feishu-config.ini"
config
=
configparser
.
ConfigParser
()
config
.
read
(
config_file
,
encoding
=
'utf-8'
)
if
not
app_token
:
app_token
=
config
.
get
(
'TOKEN'
,
'app_token'
)
# 从配置文件读取 app_token,用于认证请求
if
not
user_access_token
:
user_access_token
=
config
.
get
(
'TOKEN'
,
'user_access_token'
)
# 从配置文件读取 user_access_token,用于认证请求
if
not
page_size
:
page_size
=
config
.
get
(
'LIST_VIEWS'
,
'page_size'
,
fallback
=
100
)
# 从配置文件读取 page_size,默认为 100
if
not
page_token
:
page_token
=
config
.
get
(
'LIST_VIEWS'
,
'page_token'
,
fallback
=
None
)
# 从配置文件读取 page_token,默认为 None
if
not
table_id
:
table_id
=
config
.
get
(
'ID'
,
'table_id'
)
# 从配置文件读取 table_id,用于构建请求 URL
url
=
f"https://open.feishu.cn/open-apis/bitable/v1/apps/
{
app_token
}
/tables/
{
table_id
}
/views"
# 构建请求 URL
headers
=
{
'Authorization'
:
f'Bearer
{
user_access_token
}
'
,
# 设置请求头中的 Authorization,值为 Bearer access_token
'Content-Type'
:
'application/json; charset=utf-8'
}
params
=
{
'page_size'
:
page_size
}
# 设置请求参数中的 page_size,控制每页的视图数量
if
page_token
:
params
[
'page_token'
]
=
page_token
# 如果存在 page_token,将其添加到请求参数中,用于分页获取视图列表
response
=
requests
.
get
(
url
,
headers
=
headers
,
params
=
params
)
# 发起 GET 请求获取视图列表
return
response
.
json
()
# 返回响应体的 JSON 数据
# 列出视图命令行调用函数
def
LIST_VIEWS_CMD
():
parser
=
argparse
.
ArgumentParser
()
# 创建命令行参数解析器
parser
.
add_argument
(
'--app_token'
,
help
=
'应用的 token'
)
# 添加命令行参数 app_token,用于传递应用的 token
parser
.
add_argument
(
'--user_access_token'
,
help
=
'用户的 access token'
)
# 添加命令行参数 user_access_token,用于传递用户的 access token
parser
.
add_argument
(
'--page_size'
,
type
=
int
,
help
=
'每页的大小'
)
# 添加命令行参数 page_size,用于传递每页的大小
parser
.
add_argument
(
'--page_token'
,
help
=
'分页标记'
)
# 添加命令行参数 page_token,用于传递分页标记
parser
.
add_argument
(
'--table_id'
,
help
=
'数据表的 ID'
)
# 添加命令行参数 table_id,用于传递数据表的 ID
parser
.
add_argument
(
'--config_file'
,
default
=
"feishu-config.ini"
,
help
=
'配置文件路径'
)
# 添加命令行参数 config_file,用于传递配置文件的路径,默认为 feishu-config.ini
args
=
parser
.
parse_args
()
# 解析命令行参数
response_body
=
LIST_VIEWS
(
args
.
app_token
,
args
.
user_access_token
,
args
.
page_size
,
args
.
page_token
,
args
.
table_id
,
args
.
config_file
)
# 调用 LIST_VIEWS 函数获取视图列表
print
(
json
.
dumps
(
response_body
,
indent
=
4
))
# 打印响应体的 JSON 数据
if
__name__
==
"__main__"
:
LIST_VIEWS_CMD
()
You can’t perform that action at this time.