A project for fetching and displaying announcement notifications.
Project description
bk-notice-sdk
Quick Start
PS: 使用本sdk需要到对应环境网关的 apigw 申请权限
以下为使用本功能模块的简单配置:
-
安装版本获取平台公告模块(内部仓库):
pip install bk-notice-sdk
-
在项目配置文件中的INSTALLED_APPS内添加bk_notice_sdk:
INSTALLED_APPS += ( 'bk_notice_sdk' )
-
在项目的
urls.py
中配置路由:from bk_notice_sdk import config urlpatterns = [ ..., url(r'^{}'.format(config.ENTRANCE_URL), include(('bk_notice_sdk.urls', 'notice'), namespace='notice')), ]
若需要修改前缀路由,可在
settings.py
中修改ENTRANCE_URL
的值。详情看下面的自定义配置 -
配置环境变量(也可以在
settings.py
中配置, 见下)# 需将 bkapi.example.com 替换为真实的云 API 域名,在 PaaS 3.0 部署的应用,可从环境变量中获取 BK_API_URL_TMPL BK_API_URL_TMPL = "http://bkapi.example.com/api/{api_name}/"
-
如果需要自定义配置,在
settings.py
中添加如下配置:BK_NOTICE = { 'STAGE': 'stage', # 默认读取环境变量,如果读取不到默认为'prod' 'ENTRANCE_URL': 'routePrefix/', # 若不配置默认为'notice/' 'BK_API_URL_TMPL': "http://bkapi.example.com/api/{api_name}/" # 若不配置则读取环境变量 ... }
-
注册平台
如果需要注册本平台到通知中心可以执行以下命令:
python manage.py register_application
PS: 若本地调试不需要注册平台则不需要执行该命令
-
启动项目:
python manage.py runserver
-
可用接口
路由 方法 参数 描述 announcements/ GET 无 获取平台公告 示例: 项目运行后,访问http://ip:port/notice/announcements/即可获取当前platform(平台)的公告。
注意: 这里的 notice 路由,若在 settings.py 自定义了 ENTRANCE_URL 则为对应的路由
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
bk-notice-sdk-1.0.4.tar.gz
(6.7 kB
view hashes)