Skip to content

Commit

Permalink
Merge pull request #86 from TencentBlueKing/master
Browse files Browse the repository at this point in the history
merge from master
  • Loading branch information
zhu327 committed Jul 1, 2023
2 parents 3678cde + 450e616 commit fc34c75
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flake8_and_black.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.6.15
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: Set up Python 3.6
uses: actions/setup-python@v2
with:
python-version: 3.6
python-version: 3.6.15
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
21 changes: 0 additions & 21 deletions LICENSE.txt

This file was deleted.

14 changes: 14 additions & 0 deletions License.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
TencentBlueKing is pleased to support the open source community by making
蓝鲸智云 - 蓝鲸权限中心 (iam-python-sdk) available.
Copyright (C) 2021 THL A29 Limited,
a Tencent company. All rights reserved.
Licensed under the MIT License (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
either express or implied. See the License for the
specific language governing permissions and limitations under the License.
We undertake not to change the open source license (MIT license) applicable
to the current version of the project delivered to anyone in the future.
2 changes: 1 addition & 1 deletion iam/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = "1.3.1"
__version__ = "1.3.4"
8 changes: 4 additions & 4 deletions iam/contrib/django/dispatcher/dispatchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _dispatch(self, request):
data = json.loads(request.body)
except Exception:
logger.error("resource request(%s) failed with invalid body: %s", request_id, request.body)
return fail_response(400, "reqeust body is not a valid json", request_id)
return fail_response(400, "request body is not a valid json", request_id)

# check basic params
method = data.get("method")
Expand Down Expand Up @@ -151,7 +151,7 @@ def _dispatch_list_attr_value(self, request, data, request_id):
def _dispatch_list_instance(self, request, data, request_id):
options = self._get_options(request)

filter_obj = get_filter_obj(data.get("filter"), ["parent", "search", "resource_type_chain"])
filter_obj = get_filter_obj(data.get("filter"), ["parent", "search", "action", "resource_type_chain"])
page_obj = get_page_obj(data.get("page"))

provider = self._provider[data["type"]]
Expand Down Expand Up @@ -198,7 +198,7 @@ def _dispatch_list_instance_by_policy(self, request, data, request_id):
def _dispatch_search_instance(self, request, data, request_id):
options = self._get_options(request)

filter_obj = get_filter_obj(data.get("filter"), ["parent", "keyword"])
filter_obj = get_filter_obj(data.get("filter"), ["parent", "action", "keyword"])

if filter_obj.keyword is None or len(filter_obj.keyword) < 2:
raise KeywordTooShortException("the length of keyword should be greater than or equals to 2")
Expand All @@ -222,7 +222,7 @@ def _dispatch_search_instance(self, request, data, request_id):
def _dispatch_fetch_instance_list(self, request, data, request_id):
options = self._get_options(request)

filter_obj = get_filter_obj(data.get("filter"), ["start_time", "end_time"])
filter_obj = get_filter_obj(data.get("filter"), ["start_time", "end_time", "expression"])
page_obj = get_page_obj(data.get("page"))

provider = self._provider[data["type"]]
Expand Down
9 changes: 4 additions & 5 deletions iam/contrib/iam_migration/migrator.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,17 @@ def upsert_system_render(data):
class IAMMigrator(object):
def __init__(self, migration_json):
self.migration_json = migration_json
self._bk_app_code = getattr(settings, "APP_CODE", "")
self._bk_app_secret = settings.SECRET_KEY

def migrate(self):
app_code = settings.APP_CODE
app_secret = settings.SECRET_KEY

iam_host = ""
USE_APIGATEWAY = getattr(settings, "BK_IAM_USE_APIGATEWAY", False)
if USE_APIGATEWAY:
do_migrate.enable_use_apigateway()
iam_host = getattr(settings, "BK_IAM_APIGATEWAY_URL", "")
if iam_host == "":
raise exceptions.MigrationFailError("settings.BK_IAM_APIGATEWAY_URL should be setted")
raise exceptions.MigrationFailError("settings.BK_IAM_APIGATEWAY_URL should be set")
else:
iam_host = settings.BK_IAM_INNER_HOST

Expand All @@ -71,6 +70,6 @@ def migrate(self):
if not ok:
raise exceptions.NetworkUnreachableError("bk iam ping error")

ok = do_migrate.do_migrate(data, iam_host, app_code, app_secret)
ok = do_migrate.do_migrate(data, iam_host, self._bk_app_code, self._bk_app_secret)
if not ok:
raise exceptions.MigrationFailError("iam migrate fail")
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![](docs/resource/img/bk_iam_zh.png)
---

[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/TencentBlueKing/iam-python-sdk/blob/master/LICENSE.txt) [![Release Version](https://img.shields.io/badge/release-1.1.9-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/releases) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/pulls) [![BK Pipelines Status](https://api.bkdevops.qq.com/process/api/external/pipelines/projects/iam/p-5c359e750bb9457984ab84656651d843/badge?X-DEVOPS-PROJECT-ID=iam)](http://devops.oa.com/process/api-html/user/builds/projects/iam/pipelines/p-5c359e750bb9457984ab84656651d843/latestFinished?X-DEVOPS-PROJECT-ID=iam)
[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/TencentBlueKing/iam-python-sdk/blob/master/LICENSE.txt) [![Release Version](https://img.shields.io/badge/release-1.3.4-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/releases) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/pulls) [![BK Pipelines Status](https://api.bkdevops.qq.com/process/api/external/pipelines/projects/iam/p-5c359e750bb9457984ab84656651d843/badge?X-DEVOPS-PROJECT-ID=iam)](http://devops.oa.com/process/api-html/user/builds/projects/iam/pipelines/p-5c359e750bb9457984ab84656651d843/latestFinished?X-DEVOPS-PROJECT-ID=iam)

[(English Documents Available)](readme_en.md)

Expand Down
2 changes: 1 addition & 1 deletion readme_en.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
![](docs/resource/img/bk_iam_en.png)
---

[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/TencentBlueKing/iam-python-sdk/blob/master/LICENSE.txt) [![Release Version](https://img.shields.io/badge/release-1.1.9-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/releases) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/pulls) [![BK Pipelines Status](https://api.bkdevops.qq.com/process/api/external/pipelines/projects/iam/p-5c359e750bb9457984ab84656651d843/badge?X-DEVOPS-PROJECT-ID=iam)](http://devops.oa.com/process/api-html/user/builds/projects/iam/pipelines/p-5c359e750bb9457984ab84656651d843/latestFinished?X-DEVOPS-PROJECT-ID=iam)
[![license](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat)](https://github.com/TencentBlueKing/iam-python-sdk/blob/master/LICENSE.txt) [![Release Version](https://img.shields.io/badge/release-1.3.4-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/releases) [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/TencentBlueKing/iam-python-sdk/pulls) [![BK Pipelines Status](https://api.bkdevops.qq.com/process/api/external/pipelines/projects/iam/p-5c359e750bb9457984ab84656651d843/badge?X-DEVOPS-PROJECT-ID=iam)](http://devops.oa.com/process/api-html/user/builds/projects/iam/pipelines/p-5c359e750bb9457984ab84656651d843/latestFinished?X-DEVOPS-PROJECT-ID=iam)

## Overview

Expand Down
13 changes: 13 additions & 0 deletions release.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
版本日志
===============

# v1.3.4

- IAMMigrator 将 bk_app_code/bk_app_secret 设置为类实例属性
- cachetools 依赖版本号调整为:cachetools>=3.1.1,<6.0

# v1.3.3

- add: list_instance、search_instance 新增 action 返回

# v1.3.2

- add: fetch_instance_list 支持 expression 表达式

# v1.3.1

- add: 支持权限中心后台v2鉴权api
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

requires = [
"six>=1.11.0",
"cachetools==3.1.1",
"cachetools>=3.1.1,<6.0",
"requests",
"curlify==2.2.1",
]
Expand Down
6 changes: 3 additions & 3 deletions tests/contrib/django/dispatcher/test_dispatchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ def fetch_resource_type_schema(self, **options):
{
"method": "fetch_instance_list",
"type": "spy",
"filter": {"start_time": 1654012800, "end_time": 1654099199},
"filter": {"start_time": 1654012800, "end_time": 1654099199, "expression": None},
"page": {"limit": "limit", "offset": "offset"},
}
)
Expand All @@ -486,7 +486,7 @@ def fetch_resource_type_schema(self, **options):
resp = dispatcher._dispatch(fetch_instance_list_req)

provider.pre_fetch_instance_list.assert_called_once_with(
{"start_time": 1654012800, "end_time": 1654099199},
{"start_time": 1654012800, "end_time": 1654099199, "expression": None},
{"limit": "limit", "offset": "offset"},
language="en",
)
Expand All @@ -497,7 +497,7 @@ def fetch_resource_type_schema(self, **options):
assert "message" in resp
assert provider.fetch_instance_list_spy == {
"options": {"language": "en"},
"filter": {"start_time": 1654012800, "end_time": 1654099199},
"filter": {"start_time": 1654012800, "end_time": 1654099199, "expression": None},
"page": {"limit": "limit", "offset": "offset"},
}

Expand Down

0 comments on commit fc34c75

Please sign in to comment.