From 02ebd304d140dfea5cbf5fec3eae6f6958d4ba97 Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Tue, 2 Apr 2024 18:14:18 +0800 Subject: [PATCH 1/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=96=87=E4=BB=B6=E6=BA=90=E4=B8=8E=E5=87=AD=E8=AF=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=9A=84ApiGW=E6=8E=A5=E5=8F=A3=20#2830?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/zh/get_credential_detail.md | 77 ++++++++ .../v3/zh/get_file_source_detail.md | 85 ++++++++ .../apidocs/en/get_credential_detail.md | 79 ++++++++ .../apidocs/en/get_file_source_detail.md | 87 ++++++++ .../apidocs/zh_hans/get_credential_detail.md | 78 ++++++++ .../apidocs/zh_hans/get_file_source_detail.md | 86 ++++++++ docs/apidoc/esb/jobv3-confapis/job.yaml | 22 +++ .../api/esb/EsbFileSourceV3Resource.java | 26 +++ .../esb/v3/EsbGetFileSourceDetailV3Req.java | 21 ++ .../model/resp/esb/v3/EsbFileSourceV3DTO.java | 3 - .../api/esb/EsbFileSourceV3ResourceImpl.java | 42 +++- .../api/esb/v3/EsbCredentialV3Resource.java | 27 +++ .../request/EsbGetCredentialDetailV3Req.java | 19 ++ .../esb/v3/response/EsbCredentialV3DTO.java | 87 ++++++++ .../impl/v3/EsbCredentialResourceV3Impl.java | 38 +++- .../job/manage/model/dto/CredentialDTO.java | 22 +++ .../job/api/constant/CredentialTypeEnum.java | 52 +++++ .../job/api/constant/FileSourceTypeEnum.java | 30 +++ .../tencent/bk/job/api/util/Operations.java | 56 ++++++ .../bk/job/api/v3/constants/APIV3Urls.java | 8 + .../model/EsbCredentialSimpleInfoV3DTO.java | 44 +++++ .../job/api/v3/model/EsbCredentialV3DTO.java | 86 ++++++++ .../v3/model/EsbFileSourceDetailV3DTO.java | 110 +++++++++++ .../model/EsbFileSourceSimpleInfoV3DTO.java | 39 ++++ .../EsbCreateOrUpdateCredentialV3Req.java | 82 ++++++++ .../EsbCreateOrUpdateFileSourceV3Req.java | 44 +++++ .../request/EsbGetCredentialDetailV3Req.java | 15 ++ .../request/EsbGetFileSourceDetailV3Req.java | 15 ++ .../testcase/CredentialResourceAPITest.java | 151 ++++++++++++++ .../testcase/FileSourceResourceAPITest.java | 185 ++++++++++++++++++ 30 files changed, 1711 insertions(+), 5 deletions(-) create mode 100644 docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md create mode 100644 docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md create mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md create mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md create mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md create mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md create mode 100644 src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/req/esb/v3/EsbGetFileSourceDetailV3Req.java create mode 100644 src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java create mode 100644 src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/response/EsbCredentialV3DTO.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CredentialTypeEnum.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/constant/FileSourceTypeEnum.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialSimpleInfoV3DTO.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialV3DTO.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceSimpleInfoV3DTO.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateFileSourceV3Req.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetFileSourceDetailV3Req.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CredentialResourceAPITest.java create mode 100644 tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java diff --git a/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md b/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md new file mode 100644 index 0000000000..dcf38897f3 --- /dev/null +++ b/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md @@ -0,0 +1,77 @@ +### 功能描述 + +查询凭证详情 + +### 请求参数 + +{{ bkapi_authorization_description }} + +#### Header参数 + +| 字段 | 类型 | 必选 | 描述 | +|-----------|------------|--------|------------| +| X-Bkapi-Authorization | string | 是 | 认证信息。详情参考[调用网关 API](https://github.com/TencentBlueKing/BKDocs/blob/master/ZH/7.0/APIGateway/apigateway/use-api/use-apigw-api.md) | +| Accept | string | 是 | 固定值。application/json| +| Content-Type | string | 是 | 固定值。application/json| + +#### Query参数 + +| 字段 | 类型 | 必选 | 描述 | +|------------------------|------------|--------|------------| +| bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| bk_biz_id | long | 是 | *已弃用*。业务ID。此字段已被弃用并由字段bk_scope_type+bk_scope_id替换 | +| id | String | 是 | 凭据ID | + +### 请求参数示例 + +- GET +```json +/api/v3/get_credential_detail?bk_scope_type=biz&bk_scope_id=1&id=xxx +``` + +### 返回结果示例 + +```json +{ + "result": true, + "code": 0, + "message": "", + "data": { + "bk_scope_type": "biz", + "bk_scope_id": "2", + "id": "xxx", + "name": "xxx", + "type": "xxx", + "description": "xxx", + "creator": "admin", + "create_time": 1712049204719, + "last_modify_user": "admin", + "last_modify_time": "1712049204719" + } +} +``` + +### 返回结果参数说明 + +| 字段 | 类型 | 描述 | +|-----------|-----------|-----------| +| result | bool | 请求成功与否。true:请求成功;false请求失败 | +| code | int | 错误编码。 0表示success,>0表示失败错误 | +| message | string | 请求失败返回的错误信息| +| data | object | 请求返回的数据| +| permission | object | 权限信息| + +##### data +| 字段 | 类型 | 描述 | +| ---------------- | ------ | ------------------------------------------------------------ | +| bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| id | string | 凭据ID | +| name | string | 凭证名称 | +| type | string | 类型。可选值:APP_ID_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY| +| description | string | 描述 | +| creator | string | 作业创建人账号 | +| create_time | long | 创建时间,Unix 时间戳 | +| last_modify_user | string | 作业修改人账号 | +| last_modify_time | long | 最后修改时间,Unix 时间戳 | diff --git a/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md b/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md new file mode 100644 index 0000000000..ba9b4e4e16 --- /dev/null +++ b/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md @@ -0,0 +1,85 @@ +### 功能描述 + +查询文件源详情 + +### 请求参数 + +{{ bkapi_authorization_description }} + +#### Header参数 + +| 字段 | 类型 | 必选 | 描述 | +|-----------|------------|--------|------------| +| X-Bkapi-Authorization | string | 是 | 认证信息。详情参考[调用网关 API](https://github.com/TencentBlueKing/BKDocs/blob/master/ZH/7.0/APIGateway/apigateway/use-api/use-apigw-api.md) | +| Accept | string | 是 | 固定值。application/json| +| Content-Type | string | 是 | 固定值。application/json| + +#### Query参数 + +| 字段 | 类型 | 必选 | 描述 | +|------------------------|------------|--------|------------| +| bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| bk_biz_id | long | 是 | *已弃用*。业务ID。此字段已被弃用并由字段bk_scope_type+bk_scope_id替换 | +| code | String | 是 | 文件源code | + +### 请求参数示例 + +- GET +```json +/api/v3/get_file_source_detail?bk_scope_type=biz&bk_scope_id=1&code=1 +``` + +### 返回结果示例 + +```json +{ + "result": true, + "code": 0, + "message": "", + "data": { + "bk_scope_type": "biz", + "bk_scope_id": "2", + "id": 0, + "code": "xxx", + "alias": "xxx", + "status": 0, + "file_source_type": 3, + "is_public": false, + "credential_id": "xxx", + "enable": true, + "creator": "admin", + "create_time": 1712050614742, + "last_modify_user": "admin", + "last_modify_time": 1712050614742 + } +} +``` + +### 返回结果参数说明 + +| 字段 | 类型 | 描述 | +|-----------|-----------|-----------| +| result | bool | 请求成功与否。true:请求成功;false请求失败 | +| code | int | 错误编码。 0表示success,>0表示失败错误 | +| message | string | 请求失败返回的错误信息| +| data | object | 请求返回的数据| +| permission | object | 权限信息| + +##### data +| 字段 | 类型 | 描述 | +| ---------------- | ------ | ------------------------------------------------------------ | +| bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| id | int | 文件源ID | +| code | string | 文件源code | +| alias | string | 文件源别名 | +| status | int | 状态 | +| file_source_type | int | 类型。可选值:蓝鲸制品库 | +| is_public | bool | 是否为公用文件源 | +| credential_id | string | 凭据ID | +| enable | bool | 是否启用 | +| creator | string | 作业创建人账号 | +| create_time | long | 创建时间,Unix 时间戳 | +| last_modify_user | string | 作业修改人账号 | +| last_modify_time | long | 最后修改时间,Unix 时间戳 | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md new file mode 100644 index 0000000000..d89a489fc8 --- /dev/null +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md @@ -0,0 +1,79 @@ +### Function Description + +Query credential details + +### Request Parameters + +{{ common_args_desc }} + +#### Interface parameters + +| Fields | Type | Required | Description | +| ------------- | ------ | ---- | ------------------------------------------------------- | +| bk_scope_type | string | yes | Resource scope type. Optional values: biz - Business,biz_set - Business Set | +| bk_scope_id | string | yes | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | +| id | String | yes | Credential ID | + +### Example of request + +```json +{ + "bk_app_code": "esb_test", + "bk_app_secret": "xxx", + "bk_token": "xxx", + "bk_scope_type": "biz", + "bk_scope_id": "1", + "id": "xxx" +} +``` + +### Example of responses + +```json +{ + "result": true, + "code": 0, + "message": "", + "data": { + "bk_scope_type": "biz", + "bk_scope_id": "2", + "id": "xxx", + "name": "xxx", + "type": "xxx", + "description": "xxx", + "creator": "admin", + "create_time": 1712049204719, + "last_modify_user": "admin", + "last_modify_time": "1712049204719" + } +} +``` + +### Response Description + +#### response + +| Fields | Type | Description | +|-----------|-----------|-----------| +| result | bool | Whether the request was successful or not. True: request succeeded;False: request failed| +| code | int | Error code. 0 indicates success, >0 indicates failure| +| message | string |Error message| +| data | object |Data returned by request| +| permission | object |Permission information| +| request_id | string |Request chain id| + + +#### data + +| Fields | Type | Description | +| ---------------- | ------ | ------------------------------------------------------------ | +| bk_scope_type | string | Resource scope type. Optional values: biz - Business,biz_set - Business Set | +| bk_scope_id | string | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | +| id | string | Credential ID | +| name | string | Credential name | +| type | string | Type. Optional values:APP_ID_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY| +| description | string | Description | +| creator | string | Creator | +| create_time | long | Creation time Unix timestamp (ms) | +| last_modify_user | string | Last modify user | +| last_modify_time | long | Last modified time Unix timestamp (ms) | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md new file mode 100644 index 0000000000..016d1728ff --- /dev/null +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md @@ -0,0 +1,87 @@ +### Function Description + +Query file source details + +### Request Parameters + +{{ common_args_desc }} + +#### Interface parameters + +| Fields | Type | Required | Description | +| ------------- | ------ | ---- | ------------------------------------------------------- | +| bk_scope_type | string | yes | Resource scope type. Optional values: biz - Business,biz_set - Business Set | +| bk_scope_id | string | yes | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | +| code | String | yes | File source code | + +### Example of request + +```json +{ + "bk_app_code": "esb_test", + "bk_app_secret": "xxx", + "bk_token": "xxx", + "bk_scope_type": "biz", + "bk_scope_id": "1", + "code": "xxx" +} +``` + +### Example of responses + +```json +{ + "result": true, + "code": 0, + "message": "", + "data": { + "bk_scope_type": "biz", + "bk_scope_id": "2", + "id": 0, + "code": "xxx", + "alias": "xxx", + "status": 0, + "file_source_type": 3, + "is_public": false, + "credential_id": "xxx", + "enable": true, + "creator": "admin", + "create_time": 1712050614742, + "last_modify_user": "admin", + "last_modify_time": 1712050614742 + } +} +``` + +### Response Description + +#### response + +| Fields | Type | Description | +|-----------|-----------|-----------| +| result | bool | Whether the request was successful or not. True: request succeeded;False: request failed| +| code | int | Error code. 0 indicates success, >0 indicates failure| +| message | string |Error message| +| data | object |Data returned by request| +| permission | object |Permission information| +| request_id | string |Request chain id| + + +#### data + +| Fields | Type | Description | +| ---------------- | ------ | ------------------------------------------------------------ | +| bk_scope_type | string | Resource scope type. Optional values: biz - Business,biz_set - Business Set | +| bk_scope_id | string | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | +| id | int | File source ID | +| code | string | File source code | +| alias | string | File source alias | +| status | int | Status | +| file_source_type | int | File source type.Optional values: blueking artifactory | +| is_public | bool | Is it a public file source | +| credential_id | string | Credential ID | +| enable | bool | Enable | +| creator | string | Creator | +| create_time | long | Creation time Unix timestamp (ms) | +| last_modify_user | string | Last modify user | +| last_modify_time | long | Last modified time Unix timestamp (ms) | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md new file mode 100644 index 0000000000..6b93c72db9 --- /dev/null +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md @@ -0,0 +1,78 @@ +### 功能描述 + +查询凭证详情 + +### 请求参数 + +{{ common_args_desc }} + +#### 接口参数 + +| 字段 | 类型 | 必选 | 描述 | +| ------------- | ------ | ---- | ------------------------------------------------------- | +| bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| id | String | 是 | 凭据ID | + +### 请求参数示例 + +```json +{ + "bk_app_code": "esb_test", + "bk_app_secret": "xxx", + "bk_token": "xxx", + "bk_scope_type": "biz", + "bk_scope_id": "1", + "id": "xxx" +} +``` + +### 返回结果示例 + +```json +{ + "result": true, + "code": 0, + "message": "", + "data": { + "bk_scope_type": "biz", + "bk_scope_id": "2", + "id": "xxx", + "name": "xxx", + "type": "xxx", + "description": "xxx", + "creator": "admin", + "create_time": 1712049204719, + "last_modify_user": "admin", + "last_modify_time": "1712049204719" + } +} +``` + +### 返回结果参数说明 + +#### response + +| 字段 | 类型 | 描述 | +| ---------- | ------ | ------------------------------------------ | +| result | bool | 请求成功与否。true:请求成功;false请求失败 | +| code | int | 错误编码。 0表示success,>0表示失败错误 | +| message | string | 请求失败返回的错误信息 | +| data | object | 请求返回的数据 | +| permission | object | 权限信息 | + + +#### data + +| 字段 | 类型 | 描述 | +| ---------------- | ------ | ------------------------------------------------------------ | +| bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| id | string | 凭据ID | +| name | string | 凭证名称 | +| type | string | 类型。可选值:APP_ID_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY| +| description | string | 描述 | +| creator | string | 作业创建人账号 | +| create_time | long | 创建时间,Unix 时间戳 | +| last_modify_user | string | 作业修改人账号 | +| last_modify_time | long | 最后修改时间,Unix 时间戳 | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md new file mode 100644 index 0000000000..32e0061e8a --- /dev/null +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md @@ -0,0 +1,86 @@ +### 功能描述 + +查询文件源详情 + +### 请求参数 + +{{ common_args_desc }} + +#### 接口参数 + +| 字段 | 类型 | 必选 | 描述 | +| ------------- | ------ | ---- | ------------------------------------------------------- | +| bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| code | String | 是 | 文件源code | + +### 请求参数示例 + +```json +{ + "bk_app_code": "esb_test", + "bk_app_secret": "xxx", + "bk_token": "xxx", + "bk_scope_type": "biz", + "bk_scope_id": "1", + "code": "xxx" +} +``` + +### 返回结果示例 + +```json +{ + "result": true, + "code": 0, + "message": "", + "data": { + "bk_scope_type": "biz", + "bk_scope_id": "2", + "id": 0, + "code": "xxx", + "alias": "xxx", + "status": 0, + "file_source_type": 3, + "is_public": false, + "credential_id": "xxx", + "enable": true, + "creator": "admin", + "create_time": 1712050614742, + "last_modify_user": "admin", + "last_modify_time": 1712050614742 + } +} +``` + +### 返回结果参数说明 + +#### response + +| 字段 | 类型 | 描述 | +| ---------- | ------ | ------------------------------------------ | +| result | bool | 请求成功与否。true:请求成功;false请求失败 | +| code | int | 错误编码。 0表示success,>0表示失败错误 | +| message | string | 请求失败返回的错误信息 | +| data | object | 请求返回的数据 | +| permission | object | 权限信息 | + + +#### data + +| 字段 | 类型 | 描述 | +| ---------------- | ------ | ------------------------------------------------------------ | +| bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | +| bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | +| id | int | 文件源ID | +| code | string | 文件源code | +| alias | string | 文件源别名 | +| status | int | 状态 | +| file_source_type | int | 类型。可选值:蓝鲸制品库 | +| is_public | bool | 是否为公用文件源 | +| credential_id | string | 凭据ID | +| enable | bool | 是否启用 | +| creator | string | 作业创建人账号 | +| create_time | long | 创建时间,Unix 时间戳 | +| last_modify_user | string | 作业修改人账号 | +| last_modify_time | long | 最后修改时间,Unix 时间戳 | diff --git a/docs/apidoc/esb/jobv3-confapis/job.yaml b/docs/apidoc/esb/jobv3-confapis/job.yaml index a7822d6125..31ceb15363 100644 --- a/docs/apidoc/esb/jobv3-confapis/job.yaml +++ b/docs/apidoc/esb/jobv3-confapis/job.yaml @@ -291,6 +291,17 @@ dest_http_method: POST is_hidden: True +- path: /v2/jobv3/get_credential_detail/ + name: get_credential_detail + label: 查询凭据详情 + label_en: get credential detail + suggest_method: POST + api_type: query + comp_codename: generic.v2.jobv3.job_component + dest_path: /api/job/v3/job-manage/get_credential_detail/ + dest_http_method: POST + is_hidden: True + - path: /v2/jobv3/create_file_source/ name: create_file_source label: 新建文件源 @@ -313,6 +324,17 @@ dest_http_method: POST is_hidden: True +- path: /v2/jobv3/get_file_source_detail/ + name: get_file_source_detail + label: 查询文件源详情 + label_en: get file source detail + suggest_method: POST + api_type: query + comp_codename: generic.v2.jobv3.job_component + dest_path: /api/job/v3/job-file-gateway/get_file_source_detail/ + dest_http_method: POST + is_hidden: True + - path: /v2/jobv3/generate_local_file_upload_url/ name: generate_local_file_upload_url label: 生成本地文件上传URL diff --git a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3Resource.java b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3Resource.java index a2ebf29858..7e27cd2059 100644 --- a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3Resource.java +++ b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3Resource.java @@ -28,12 +28,16 @@ import com.tencent.bk.job.common.constant.JobCommonHeaders; import com.tencent.bk.job.common.esb.model.EsbResp; import com.tencent.bk.job.file_gateway.model.req.esb.v3.EsbCreateOrUpdateFileSourceV3Req; +import com.tencent.bk.job.file_gateway.model.req.esb.v3.EsbGetFileSourceDetailV3Req; import com.tencent.bk.job.file_gateway.model.resp.esb.v3.EsbFileSourceSimpleInfoV3DTO; +import com.tencent.bk.job.file_gateway.model.resp.esb.v3.EsbFileSourceV3DTO; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -62,4 +66,26 @@ EsbResp updateFileSource( EsbCreateOrUpdateFileSourceV3Req req ); + @GetMapping("/get_file_source_detail") + EsbResp getFileSourceDetail( + @RequestHeader(value = JobCommonHeaders.USERNAME) String username, + @RequestHeader(value = JobCommonHeaders.APP_CODE) String appCode, + @RequestParam(value = "bk_biz_id", required = false) Long bizId, + @RequestParam(value = "bk_scope_type", required = false) String scopeType, + @RequestParam(value = "bk_scope_id", required = false) String scopeId, + @RequestParam(value = "code") String code); + + /** + * 获取文件源详情 + * + * @param req 查询请求 + * @return 文件源详情 + */ + @PostMapping("/get_file_source_detail") + EsbResp getFileSourceDetailUsingPost( + @RequestHeader(value = JobCommonHeaders.USERNAME) String username, + @RequestHeader(value = JobCommonHeaders.APP_CODE) String appCode, + @RequestBody + @Validated + EsbGetFileSourceDetailV3Req req); } diff --git a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/req/esb/v3/EsbGetFileSourceDetailV3Req.java b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/req/esb/v3/EsbGetFileSourceDetailV3Req.java new file mode 100644 index 0000000000..44ea316d1a --- /dev/null +++ b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/req/esb/v3/EsbGetFileSourceDetailV3Req.java @@ -0,0 +1,21 @@ +package com.tencent.bk.job.file_gateway.model.req.esb.v3; + +import com.tencent.bk.job.common.esb.model.EsbAppScopeReq; +import com.tencent.bk.job.common.validation.NotBlankField; +import com.tencent.bk.job.common.validation.NotContainSpecialChar; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class EsbGetFileSourceDetailV3Req extends EsbAppScopeReq { + + /** + * 文件源Code + */ + @ApiModelProperty(value = "文件源Code") + @NotBlankField(fieldName = "code") + @NotContainSpecialChar(fieldName = "code") + private String code; +} diff --git a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java index 188a87082a..3a8cff9846 100644 --- a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java +++ b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java @@ -26,9 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonPropertyDescription; -import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.tencent.bk.job.common.esb.model.EsbAppScopeDTO; -import com.tencent.bk.job.common.util.json.LongTimestampSerializer; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; @@ -106,7 +104,6 @@ public class EsbFileSourceV3DTO extends EsbAppScopeDTO { /** * 更新时间 */ - @JsonSerialize(using = LongTimestampSerializer.class) @JsonProperty("last_modify_time") @JsonPropertyDescription("Last modify time") private Long lastModifyTime; diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java index f7e34dd4d8..ed7344f856 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java @@ -3,17 +3,22 @@ import com.tencent.bk.audit.annotations.AuditEntry; import com.tencent.bk.audit.annotations.AuditRequestBody; import com.tencent.bk.job.common.constant.ErrorCode; +import com.tencent.bk.job.common.esb.metrics.EsbApiTimed; import com.tencent.bk.job.common.esb.model.EsbResp; import com.tencent.bk.job.common.exception.FailedPreconditionException; import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.common.exception.MissingParameterException; import com.tencent.bk.job.common.iam.constant.ActionId; +import com.tencent.bk.job.common.metrics.CommonMetricNames; +import com.tencent.bk.job.common.service.AppScopeMappingService; import com.tencent.bk.job.file_gateway.consts.WorkerSelectModeEnum; import com.tencent.bk.job.file_gateway.consts.WorkerSelectScopeEnum; import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO; import com.tencent.bk.job.file_gateway.model.dto.FileSourceTypeDTO; import com.tencent.bk.job.file_gateway.model.req.esb.v3.EsbCreateOrUpdateFileSourceV3Req; +import com.tencent.bk.job.file_gateway.model.req.esb.v3.EsbGetFileSourceDetailV3Req; import com.tencent.bk.job.file_gateway.model.resp.esb.v3.EsbFileSourceSimpleInfoV3DTO; +import com.tencent.bk.job.file_gateway.model.resp.esb.v3.EsbFileSourceV3DTO; import com.tencent.bk.job.file_gateway.service.FileSourceService; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; @@ -27,14 +32,18 @@ public class EsbFileSourceV3ResourceImpl implements EsbFileSourceV3Resource { private final FileSourceService fileSourceService; + private final AppScopeMappingService appScopeMappingService; @Autowired - public EsbFileSourceV3ResourceImpl(FileSourceService fileSourceService) { + public EsbFileSourceV3ResourceImpl(FileSourceService fileSourceService, + AppScopeMappingService appScopeMappingService) { this.fileSourceService = fileSourceService; + this.appScopeMappingService = appScopeMappingService; } @Override @AuditEntry(actionId = ActionId.CREATE_FILE_SOURCE) + @EsbApiTimed(value = CommonMetricNames.ESB_API, extraTags = {"api_name", "create_file_source"}) public EsbResp createFileSource( String username, String appCode, @@ -48,6 +57,7 @@ public EsbResp createFileSource( @Override @AuditEntry(actionId = ActionId.MANAGE_FILE_SOURCE) + @EsbApiTimed(value = CommonMetricNames.ESB_API, extraTags = {"api_name", "update_file_source"}) public EsbResp updateFileSource( String username, String appCode, @@ -60,6 +70,36 @@ public EsbResp updateFileSource( return EsbResp.buildSuccessResp(new EsbFileSourceSimpleInfoV3DTO(updateFileSource.getId())); } + @Override + @AuditEntry(actionId = ActionId.VIEW_FILE_SOURCE) + @EsbApiTimed(value = CommonMetricNames.ESB_API, extraTags = {"api_name", "get_file_source_detail"}) + public EsbResp getFileSourceDetail( + String username, + String appCode, + Long bizId, + String scopeType, + String scopeId, + String code) { + EsbGetFileSourceDetailV3Req req = new EsbGetFileSourceDetailV3Req(); + req.setBizId(bizId); + req.setScopeType(scopeType); + req.setScopeId(scopeId); + req.setCode(code); + req.fillAppResourceScope(appScopeMappingService); + return getFileSourceDetailUsingPost(username, appCode, req); + } + + @Override + @AuditEntry(actionId = ActionId.VIEW_FILE_SOURCE) + @EsbApiTimed(value = CommonMetricNames.ESB_API, extraTags = {"api_name", "get_file_source_detail"}) + public EsbResp getFileSourceDetailUsingPost( + String username, + String appCode, + @AuditRequestBody EsbGetFileSourceDetailV3Req req) { + FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(req.getCode()); + return EsbResp.buildSuccessResp(FileSourceDTO.toEsbFileSourceV3DTO(fileSourceDTO)); + } + private void checkCommonParam(EsbCreateOrUpdateFileSourceV3Req req) { if (StringUtils.isBlank(req.getAlias())) { throw new InvalidParamException(ErrorCode.MISSING_PARAM_WITH_PARAM_NAME, new String[]{"alias"}); diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java index 7c6b55cf33..d3ad0a0be6 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java @@ -28,12 +28,16 @@ import com.tencent.bk.job.common.constant.JobCommonHeaders; import com.tencent.bk.job.common.esb.model.EsbResp; import com.tencent.bk.job.manage.model.esb.v3.request.EsbCreateOrUpdateCredentialV3Req; +import com.tencent.bk.job.manage.model.esb.v3.request.EsbGetCredentialDetailV3Req; import com.tencent.bk.job.manage.model.esb.v3.response.EsbCredentialSimpleInfoV3DTO; +import com.tencent.bk.job.manage.model.esb.v3.response.EsbCredentialV3DTO; import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestHeader; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; /** @@ -62,4 +66,27 @@ EsbResp updateCredential( EsbCreateOrUpdateCredentialV3Req req ); + @GetMapping("/get_credential_detail") + EsbResp getCredentialDetail( + @RequestHeader(value = JobCommonHeaders.USERNAME) String username, + @RequestHeader(value = JobCommonHeaders.APP_CODE) String appCode, + @RequestParam(value = "bk_biz_id", required = false) Long bizId, + @RequestParam(value = "bk_scope_type", required = false) String scopeType, + @RequestParam(value = "bk_scope_id", required = false) String scopeId, + @RequestParam(value = "id") String id); + + /** + * 获取凭据详情 + * + * @param req 查询请求 + * @return 凭据详情 + */ + @PostMapping("/get_credential_detail") + EsbResp getCredentialDetailUsingPost( + @RequestHeader(value = JobCommonHeaders.USERNAME) String username, + @RequestHeader(value = JobCommonHeaders.APP_CODE) String appCode, + @RequestBody + @Validated + EsbGetCredentialDetailV3Req req); + } diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java new file mode 100644 index 0000000000..338306e6ca --- /dev/null +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java @@ -0,0 +1,19 @@ +package com.tencent.bk.job.manage.model.esb.v3.request; + +import com.tencent.bk.job.common.esb.model.EsbAppScopeReq; +import com.tencent.bk.job.common.validation.NotBlankField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class EsbGetCredentialDetailV3Req extends EsbAppScopeReq { + + /** + * 凭据id + */ + @ApiModelProperty(value = "凭据id") + @NotBlankField(fieldName = "id") + private String id; +} diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/response/EsbCredentialV3DTO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/response/EsbCredentialV3DTO.java new file mode 100644 index 0000000000..bbd4a585a4 --- /dev/null +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/response/EsbCredentialV3DTO.java @@ -0,0 +1,87 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.manage.model.esb.v3.response; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import com.tencent.bk.job.common.esb.model.EsbAppScopeDTO; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@EqualsAndHashCode(callSuper = true) +@Data +@NoArgsConstructor +public class EsbCredentialV3DTO extends EsbAppScopeDTO { + + /** + * id + */ + @JsonPropertyDescription("Credential id") + private String id; + + /** + * 凭证名称 + */ + @JsonPropertyDescription("Credential name") + private String name; + + /** + * 凭证类型 + */ + @JsonPropertyDescription("Credential type") + private String type; + + /** + * 描述 + */ + @JsonPropertyDescription("Credential name") + private String description; + + /** + * 创建人 + */ + @JsonPropertyDescription("Creator") + private String creator; + /** + * 创建时间 + */ + @JsonProperty("create_time") + @JsonPropertyDescription("Create time") + private Long createTime; + /** + * 更新人 + */ + @JsonProperty("last_modify_user") + @JsonPropertyDescription("Last modify user") + private String lastModifyUser; + + /** + * 更新时间 + */ + @JsonProperty("last_modify_time") + @JsonPropertyDescription("Last modify time") + private Long lastModifyTime; +} diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/impl/v3/EsbCredentialResourceV3Impl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/impl/v3/EsbCredentialResourceV3Impl.java index 90b0973d23..e6eeb134df 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/impl/v3/EsbCredentialResourceV3Impl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/impl/v3/EsbCredentialResourceV3Impl.java @@ -27,14 +27,19 @@ import com.tencent.bk.audit.annotations.AuditEntry; import com.tencent.bk.audit.annotations.AuditRequestBody; import com.tencent.bk.job.common.constant.ErrorCode; +import com.tencent.bk.job.common.esb.metrics.EsbApiTimed; import com.tencent.bk.job.common.esb.model.EsbResp; import com.tencent.bk.job.common.exception.InvalidParamException; import com.tencent.bk.job.common.iam.constant.ActionId; +import com.tencent.bk.job.common.metrics.CommonMetricNames; +import com.tencent.bk.job.common.service.AppScopeMappingService; import com.tencent.bk.job.manage.api.common.constants.CredentialTypeEnum; import com.tencent.bk.job.manage.api.esb.v3.EsbCredentialV3Resource; import com.tencent.bk.job.manage.model.dto.CredentialDTO; import com.tencent.bk.job.manage.model.esb.v3.request.EsbCreateOrUpdateCredentialV3Req; +import com.tencent.bk.job.manage.model.esb.v3.request.EsbGetCredentialDetailV3Req; import com.tencent.bk.job.manage.model.esb.v3.response.EsbCredentialSimpleInfoV3DTO; +import com.tencent.bk.job.manage.model.esb.v3.response.EsbCredentialV3DTO; import com.tencent.bk.job.manage.model.web.request.CredentialCreateUpdateReq; import com.tencent.bk.job.manage.service.CredentialService; import lombok.extern.slf4j.Slf4j; @@ -47,10 +52,13 @@ @Slf4j public class EsbCredentialResourceV3Impl implements EsbCredentialV3Resource { private final CredentialService credentialService; + private final AppScopeMappingService appScopeMappingService; @Autowired - public EsbCredentialResourceV3Impl(CredentialService credentialService) { + public EsbCredentialResourceV3Impl(CredentialService credentialService, + AppScopeMappingService appScopeMappingService) { this.credentialService = credentialService; + this.appScopeMappingService = appScopeMappingService; } @Override @@ -100,6 +108,34 @@ public EsbResp updateCredential( return EsbResp.buildSuccessResp(updateCredential.toEsbCredentialSimpleInfoV3DTO()); } + @Override + @EsbApiTimed(value = CommonMetricNames.ESB_API, extraTags = {"api_name", "get_credential_detail"}) + public EsbResp getCredentialDetail( + String username, + String appCode, + Long bizId, + String scopeType, + String scopeId, + String id) { + EsbGetCredentialDetailV3Req req = new EsbGetCredentialDetailV3Req(); + req.setBizId(bizId); + req.setScopeType(scopeType); + req.setScopeId(scopeId); + req.setId(id); + req.fillAppResourceScope(appScopeMappingService); + return getCredentialDetailUsingPost(username, appCode, req); + } + + @Override + @EsbApiTimed(value = CommonMetricNames.ESB_API, extraTags = {"api_name", "get_credential_detail"}) + public EsbResp getCredentialDetailUsingPost( + String username, + String appCode, + @AuditRequestBody EsbGetCredentialDetailV3Req req) { + CredentialDTO credentialDTO = credentialService.getCredentialById(req.getId()); + return EsbResp.buildSuccessResp(credentialDTO.toEsbCredentialV3DTO()); + } + private void checkUpdateParam(EsbCreateOrUpdateCredentialV3Req req) { if (StringUtils.isBlank(req.getId())) { throw new InvalidParamException(ErrorCode.ILLEGAL_PARAM_WITH_PARAM_NAME_AND_REASON, diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/CredentialDTO.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/CredentialDTO.java index 2fac22c632..790afdc3d0 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/CredentialDTO.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/model/dto/CredentialDTO.java @@ -25,8 +25,12 @@ package com.tencent.bk.job.manage.model.dto; import com.tencent.bk.job.common.model.dto.CommonCredential; +import com.tencent.bk.job.common.model.dto.ResourceScope; +import com.tencent.bk.job.common.service.AppScopeMappingService; +import com.tencent.bk.job.common.util.ApplicationContextRegister; import com.tencent.bk.job.manage.api.common.constants.CredentialTypeEnum; import com.tencent.bk.job.manage.model.esb.v3.response.EsbCredentialSimpleInfoV3DTO; +import com.tencent.bk.job.manage.model.esb.v3.response.EsbCredentialV3DTO; import com.tencent.bk.job.manage.model.inner.resp.ServiceCredentialDTO; import com.tencent.bk.job.manage.model.web.vo.CredentialBasicVO; import com.tencent.bk.job.manage.model.web.vo.CredentialVO; @@ -117,6 +121,24 @@ public ServiceCredentialDTO toServiceCredentialDTO() { return serviceCredentialDTO; } + public EsbCredentialV3DTO toEsbCredentialV3DTO() { + EsbCredentialV3DTO esbCredentialV3DTO = new EsbCredentialV3DTO(); + esbCredentialV3DTO.setId(id); + esbCredentialV3DTO.setName(name); + esbCredentialV3DTO.setType(type); + esbCredentialV3DTO.setDescription(description); + AppScopeMappingService appScopeMappingService = + ApplicationContextRegister.getBean(AppScopeMappingService.class); + ResourceScope resourceScope = appScopeMappingService.getScopeByAppId(appId); + esbCredentialV3DTO.setScopeType(resourceScope.getType().getValue()); + esbCredentialV3DTO.setScopeId(resourceScope.getId()); + esbCredentialV3DTO.setCreator(creator); + esbCredentialV3DTO.setCreateTime(createTime); + esbCredentialV3DTO.setLastModifyUser(lastModifyUser); + esbCredentialV3DTO.setLastModifyTime(lastModifyTime); + return esbCredentialV3DTO; + } + public EsbCredentialSimpleInfoV3DTO toEsbCredentialSimpleInfoV3DTO() { return new EsbCredentialSimpleInfoV3DTO(id, name); } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CredentialTypeEnum.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CredentialTypeEnum.java new file mode 100644 index 0000000000..404bd38475 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/CredentialTypeEnum.java @@ -0,0 +1,52 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.constant; + +public enum CredentialTypeEnum { + APP_ID_SECRET_KEY(1, "AccessKey+SecretKey"), + PASSWORD(2, "单一密码"), + USERNAME_PASSWORD(3, "用户名+密码"), + SECRET_KEY(4, "单一SecretKey"); + + private final Integer value; + private final String description; + + public static String getAllNameStr() { + StringBuilder sb = new StringBuilder(); + CredentialTypeEnum[] values = CredentialTypeEnum.values(); + for (int i = 0; i < values.length; i++) { + sb.append(values[i].name()); + if (i < values.length - 1) { + sb.append(","); + } + } + return sb.toString(); + } + + CredentialTypeEnum(Integer type, String description) { + this.value = type; + this.description = description; + } +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/FileSourceTypeEnum.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/FileSourceTypeEnum.java new file mode 100644 index 0000000000..36ed5f8354 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/constant/FileSourceTypeEnum.java @@ -0,0 +1,30 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.constant; + +public enum FileSourceTypeEnum { + TENCENT_CLOUD_COS, + BLUEKING_ARTIFACTORY +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java index 483fdc36a9..abafd69502 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/util/Operations.java @@ -1,5 +1,7 @@ package com.tencent.bk.job.api.util; +import com.tencent.bk.job.api.constant.CredentialTypeEnum; +import com.tencent.bk.job.api.constant.FileSourceTypeEnum; import com.tencent.bk.job.api.constant.HighRiskGrammarActionEnum; import com.tencent.bk.job.api.constant.ResourceScopeTypeEnum; import com.tencent.bk.job.api.constant.ScriptTypeEnum; @@ -7,8 +9,10 @@ import com.tencent.bk.job.api.props.TestProps; import com.tencent.bk.job.api.v3.constants.APIV3Urls; import com.tencent.bk.job.api.v3.model.EsbAccountV3BasicDTO; +import com.tencent.bk.job.api.v3.model.EsbCredentialSimpleInfoV3DTO; import com.tencent.bk.job.api.v3.model.EsbCronInfoV3DTO; import com.tencent.bk.job.api.v3.model.EsbDangerousRuleV3DTO; +import com.tencent.bk.job.api.v3.model.EsbFileSourceSimpleInfoV3DTO; import com.tencent.bk.job.api.v3.model.EsbFileSourceV3DTO; import com.tencent.bk.job.api.v3.model.EsbJobExecuteV3DTO; import com.tencent.bk.job.api.v3.model.EsbPageDataV3; @@ -17,6 +21,8 @@ import com.tencent.bk.job.api.v3.model.EsbServerV3DTO; import com.tencent.bk.job.api.v3.model.HostDTO; import com.tencent.bk.job.api.v3.model.request.EsbCreateDangerousRuleV3Req; +import com.tencent.bk.job.api.v3.model.request.EsbCreateOrUpdateCredentialV3Req; +import com.tencent.bk.job.api.v3.model.request.EsbCreateOrUpdateFileSourceV3Req; import com.tencent.bk.job.api.v3.model.request.EsbCreatePublicScriptV3Req; import com.tencent.bk.job.api.v3.model.request.EsbCreateScriptV3Request; import com.tencent.bk.job.api.v3.model.request.EsbDeleteCronV3Request; @@ -35,7 +41,9 @@ import java.time.LocalDateTime; import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static com.tencent.bk.job.api.constant.Constant.SHELL_SCRIPT_CONTENT_BASE64; import static io.restassured.RestAssured.given; @@ -365,6 +373,54 @@ public static Long getTaskPlanId() { return null; } + public static EsbFileSourceSimpleInfoV3DTO createFileSource() { + EsbCreateOrUpdateFileSourceV3Req req = new EsbCreateOrUpdateFileSourceV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setCode(TestValueGenerator.generateUniqueStrValue("file_source_code", 50)); + req.setAlias(TestValueGenerator.generateUniqueStrValue("file_source_alias", 50)); + req.setType(FileSourceTypeEnum.BLUEKING_ARTIFACTORY.name()); + Map accessParams = new HashMap<>(); + accessParams.put("base_url", "https://bkrepo.com"); + req.setAccessParams(accessParams); + req.setCredentialId(TestValueGenerator.generateUniqueStrValue("credential_id", 50)); + EsbFileSourceSimpleInfoV3DTO fileSourceSimpleInfoV3DTO = given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .statusCode(200) + .extract() + .body() + .as(new TypeRef>() { + }) + .getData(); + fileSourceSimpleInfoV3DTO.setCode(req.getCode()); + return fileSourceSimpleInfoV3DTO; + } + + public static EsbCredentialSimpleInfoV3DTO createCredential() { + EsbCreateOrUpdateCredentialV3Req req = new EsbCreateOrUpdateCredentialV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setName(TestValueGenerator.generateUniqueStrValue("credential_name", 50)); + req.setDescription(TestValueGenerator.generateUniqueStrValue("credential_desc", 50)); + req.setType(CredentialTypeEnum.USERNAME_PASSWORD.name()); + req.setCredentialUsername("admin"); + req.setCredentialPassword("password"); + return given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_CREDENTIAL) + .then() + .statusCode(200) + .extract() + .body() + .as(new TypeRef>() { + }) + .getData(); + } + private static String buildJobName() { return "api.test." + DateUtils.formatLocalDateTime(LocalDateTime.now(), "yyyyMMddhhmmssSSS"); } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java index 42426a2ff6..78b109206a 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/constants/APIV3Urls.java @@ -73,4 +73,12 @@ public interface APIV3Urls { String GET_JOB_PLAN_LIST = "/api/job/v3/job-manage/get_job_plan_list"; + + String CREATE_FILE_SOURCE = "/api/job/v3/job-file-gateway/create_file_source"; + String UPDATE_FILE_SOURCE = "/api/job/v3/job-file-gateway/update_file_source"; + String GET_FILE_SOURCE_DETAIL = "/api/job/v3/job-file-gateway/get_file_source_detail"; + + String CREATE_CREDENTIAL = "/api/job/v3/job-manage/create_credential"; + String UPDATE_CREDENTIAL = "/api/job/v3/job-manage/update_credential"; + String GET_CREDENTIAL_DETAIL = "/api/job/v3/job-manage/get_credential_detail"; } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialSimpleInfoV3DTO.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialSimpleInfoV3DTO.java new file mode 100644 index 0000000000..77de48825a --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialSimpleInfoV3DTO.java @@ -0,0 +1,44 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model; + +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +public class EsbCredentialSimpleInfoV3DTO { + @JsonPropertyDescription("Credential id") + private String id; + + @JsonPropertyDescription("Credential name") + private String name; + + public EsbCredentialSimpleInfoV3DTO(String id, String name) { + this.id = id; + this.name = name; + } +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialV3DTO.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialV3DTO.java new file mode 100644 index 0000000000..739903ca57 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbCredentialV3DTO.java @@ -0,0 +1,86 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@EqualsAndHashCode(callSuper = true) +@Data +@NoArgsConstructor +public class EsbCredentialV3DTO extends EsbAppScopeDTO { + + /** + * id + */ + @JsonPropertyDescription("Credential id") + private String id; + + /** + * 凭证名称 + */ + @JsonPropertyDescription("Credential name") + private String name; + + /** + * 凭证类型 + */ + @JsonPropertyDescription("Credential type") + private String type; + + /** + * 描述 + */ + @JsonPropertyDescription("Credential name") + private String description; + + /** + * 创建人 + */ + @JsonPropertyDescription("Creator") + private String creator; + /** + * 创建时间 + */ + @JsonProperty("create_time") + @JsonPropertyDescription("Create time") + private Long createTime; + /** + * 更新人 + */ + @JsonProperty("last_modify_user") + @JsonPropertyDescription("Last modify user") + private String lastModifyUser; + + /** + * 更新时间 + */ + @JsonProperty("last_modify_time") + @JsonPropertyDescription("Last modify time") + private Long lastModifyTime; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java new file mode 100644 index 0000000000..871389e7c1 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java @@ -0,0 +1,110 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonPropertyDescription; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@EqualsAndHashCode(callSuper = true) +@Data +@NoArgsConstructor +public class EsbFileSourceDetailV3DTO extends EsbAppScopeDTO { + /** + * id + */ + @JsonPropertyDescription("File source id") + private Integer id; + /** + * 文件源标识 + */ + @JsonPropertyDescription("File source code") + private String code; + + /** + * 文件源别名 + */ + @JsonPropertyDescription("File source alias") + private String alias; + /** + * 状态 + */ + @JsonPropertyDescription("File source status") + private Integer status; + /** + * 类型 + */ + @JsonProperty("file_source_type") + @JsonPropertyDescription("File source type") + private Integer fileSourceType; + + /** + * 是否为公共文件源 + */ + @JsonProperty("is_public") + @JsonPropertyDescription("Is public file source") + private boolean publicFlag; + + /** + * 凭据Id + */ + @JsonPropertyDescription("File source credential id") + @JsonProperty("credential_id") + private String credentialId; + + /** + * 是否启用 + */ + @JsonPropertyDescription("Is file source enabled") + private Boolean enable; + + /** + * 创建人 + */ + @JsonPropertyDescription("Creator") + private String creator; + /** + * 创建时间 + */ + @JsonProperty("create_time") + @JsonPropertyDescription("Create time") + private Long createTime; + /** + * 更新人 + */ + @JsonProperty("last_modify_user") + @JsonPropertyDescription("Last modify user") + private String lastModifyUser; + + /** + * 更新时间 + */ + @JsonProperty("last_modify_time") + @JsonPropertyDescription("Last modify time") + private Long lastModifyTime; + +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceSimpleInfoV3DTO.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceSimpleInfoV3DTO.java new file mode 100644 index 0000000000..e9d1bdbd9f --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceSimpleInfoV3DTO.java @@ -0,0 +1,39 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class EsbFileSourceSimpleInfoV3DTO { + + private Integer id; + + private String code; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java new file mode 100644 index 0000000000..f6ae270231 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java @@ -0,0 +1,82 @@ +/* + * Tencent is pleased to support the open source community by making BK-JOB蓝鲸智云作业平台 available. + * + * Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved. + * + * BK-JOB蓝鲸智云作业平台 is licensed under the MIT License. + * + * License for BK-JOB蓝鲸智云作业平台: + * -------------------------------------------------------------------- + * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated + * documentation files (the "Software"), to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and + * to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of + * the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO + * THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +package com.tencent.bk.job.api.v3.model.request; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 新建凭据请求 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class EsbCreateOrUpdateCredentialV3Req extends EsbAppScopeReq { + + /** + * 凭据ID + */ + private String id; + + /** + * 凭据名称 + */ + private String name; + + /** + * 凭据类型 + */ + private String type; + + /** + * 描述 + */ + private String description; + + /** + * AccessKey + */ + @JsonProperty("credential_access_key") + private String credentialAccessKey; + + /** + * SecretKey + */ + @JsonProperty("credential_secret_key") + private String credentialSecretKey; + + /** + * Username + */ + @JsonProperty("credential_username") + private String credentialUsername; + + /** + * Password + */ + @JsonProperty("credential_password") + private String credentialPassword; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateFileSourceV3Req.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateFileSourceV3Req.java new file mode 100644 index 0000000000..27140b3fa7 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateFileSourceV3Req.java @@ -0,0 +1,44 @@ +package com.tencent.bk.job.api.v3.model.request; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.HashMap; +import java.util.Map; + +@EqualsAndHashCode(callSuper = true) +@Data +public class EsbCreateOrUpdateFileSourceV3Req extends EsbAppScopeReq { + + /** + * 文件源Code + */ + private String code; + /** + * 文件源别名 + */ + private String alias; + /** + * 文件源类型 + */ + private String type; + + /** + * 文件源信息Map + */ + @JsonProperty(value = "access_params") + private Map accessParams = new HashMap<>(); + + /** + * 文件源凭证Id + */ + @JsonProperty(value = "credential_id") + private String credentialId; + /** + * 文件前缀 + */ + @JsonProperty(value = "file_prefix") + private String filePrefix = ""; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java new file mode 100644 index 0000000000..480442bd67 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java @@ -0,0 +1,15 @@ +package com.tencent.bk.job.api.v3.model.request; + +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class EsbGetCredentialDetailV3Req extends EsbAppScopeReq { + + /** + * 凭据id + */ + private String id; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetFileSourceDetailV3Req.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetFileSourceDetailV3Req.java new file mode 100644 index 0000000000..1626aa9fb5 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetFileSourceDetailV3Req.java @@ -0,0 +1,15 @@ +package com.tencent.bk.job.api.v3.model.request; + +import com.tencent.bk.job.api.model.EsbAppScopeReq; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +public class EsbGetFileSourceDetailV3Req extends EsbAppScopeReq { + + /** + * 文件源Code + */ + private String code; +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CredentialResourceAPITest.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CredentialResourceAPITest.java new file mode 100644 index 0000000000..ab6f677ccd --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/CredentialResourceAPITest.java @@ -0,0 +1,151 @@ +package com.tencent.bk.job.api.v3.testcase; + +import com.tencent.bk.job.api.constant.CredentialTypeEnum; +import com.tencent.bk.job.api.constant.ErrorCode; +import com.tencent.bk.job.api.constant.ResourceScopeTypeEnum; +import com.tencent.bk.job.api.model.EsbResp; +import com.tencent.bk.job.api.props.TestProps; +import com.tencent.bk.job.api.util.ApiUtil; +import com.tencent.bk.job.api.util.JsonUtil; +import com.tencent.bk.job.api.util.Operations; +import com.tencent.bk.job.api.util.TestValueGenerator; +import com.tencent.bk.job.api.v3.constants.APIV3Urls; +import com.tencent.bk.job.api.v3.model.EsbCredentialSimpleInfoV3DTO; +import com.tencent.bk.job.api.v3.model.request.EsbCreateOrUpdateCredentialV3Req; +import com.tencent.bk.job.api.v3.model.request.EsbGetCredentialDetailV3Req; +import io.restassured.common.mapper.TypeRef; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.List; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.notNullValue; + +/** + * 凭证 API 测试 + */ +@DisplayName("v3.CredentialResourceAPITest") +class CredentialResourceAPITest extends BaseTest { + + private static final List createdCredentialList = new ArrayList<>(); + + @Nested + class CredentialCreateTest { + @Test + @DisplayName("测试凭证正常创建") + void testCreateCredential() { + EsbCreateOrUpdateCredentialV3Req req = new EsbCreateOrUpdateCredentialV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setName(TestValueGenerator.generateUniqueStrValue("credential_name", 50)); + req.setDescription(TestValueGenerator.generateUniqueStrValue("credential_desc", 50)); + req.setType(CredentialTypeEnum.USERNAME_PASSWORD.name()); + req.setCredentialUsername("admin"); + req.setCredentialPassword("password"); + EsbCredentialSimpleInfoV3DTO createdCredential = + given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_CREDENTIAL) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .extract() + .body() + .as(new TypeRef>() { + }) + .getData(); + createdCredentialList.add(createdCredential); + } + + @Test + @DisplayName("异常创建凭证测试-比如参数校验不通过") + void givenInvalidCreateCredentialParamThenFail() { + EsbCreateOrUpdateCredentialV3Req req = new EsbCreateOrUpdateCredentialV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setName(TestValueGenerator.generateUniqueStrValue("credential_name", 50)); + req.setDescription(TestValueGenerator.generateUniqueStrValue("credential_desc", 50)); + req.setType(CredentialTypeEnum.USERNAME_PASSWORD.name()); + req.setCredentialUsername("admin"); + req.setCredentialPassword("password"); + + req.setName(null); + // 名称为空,创建失败 + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_CREDENTIAL) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.ILLEGAL_PARAM_WITH_PARAM_NAME_AND_REASON)); + + req.setName(TestValueGenerator.generateUniqueStrValue("credential_name", 50)); + req.setType(null); + // 凭证类型为空,创建失败 + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_CREDENTIAL) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.ILLEGAL_PARAM_WITH_PARAM_NAME_AND_REASON)); + } + } + + @Nested + class CredentialGetTest { + @Test + @DisplayName("测试查询凭证-通过id查询详情") + void testGetCredentialDetail() { + EsbCredentialSimpleInfoV3DTO CredentialSimpleInfoV3DTO = Operations.createCredential(); + createdCredentialList.add(CredentialSimpleInfoV3DTO); + EsbGetCredentialDetailV3Req req = new EsbGetCredentialDetailV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setId(CredentialSimpleInfoV3DTO.getId()); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.GET_CREDENTIAL_DETAIL) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(req.getId())) + .body("data.name", notNullValue()) + .body("data.type", notNullValue()) + .body("data.description", notNullValue()) + .body("data.bk_scope_type", equalTo(req.getScopeType())) + .body("data.bk_scope_id", equalTo(req.getScopeId())) + .body("data.creator", notNullValue()) + .body("data.create_time", greaterThan(0L)) + .body("data.last_modify_user", equalTo(TestProps.DEFAULT_TEST_USER)) + .body("data.last_modify_time", greaterThan(0L)); + } + } + + @Nested + class CredentialUpdateTest { + // 更新操作 + @Test + @DisplayName("测试凭证修改") + void testUpdateCredential() { + EsbCredentialSimpleInfoV3DTO CredentialSimpleInfoV3DTO = Operations.createCredential(); + createdCredentialList.add(CredentialSimpleInfoV3DTO); + EsbCreateOrUpdateCredentialV3Req req = new EsbCreateOrUpdateCredentialV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setId(CredentialSimpleInfoV3DTO.getId()); + req.setName(TestValueGenerator.generateUniqueStrValue("update_credential_name", 50)); + req.setType(CredentialTypeEnum.PASSWORD.name()); + req.setCredentialPassword("password"); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.UPDATE_CREDENTIAL) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(CredentialSimpleInfoV3DTO.getId())); + } + } +} diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java new file mode 100644 index 0000000000..3ac56789b1 --- /dev/null +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java @@ -0,0 +1,185 @@ +package com.tencent.bk.job.api.v3.testcase; + +import com.tencent.bk.job.api.constant.ErrorCode; +import com.tencent.bk.job.api.constant.FileSourceTypeEnum; +import com.tencent.bk.job.api.constant.ResourceScopeTypeEnum; +import com.tencent.bk.job.api.model.EsbResp; +import com.tencent.bk.job.api.props.TestProps; +import com.tencent.bk.job.api.util.ApiUtil; +import com.tencent.bk.job.api.util.JsonUtil; +import com.tencent.bk.job.api.util.Operations; +import com.tencent.bk.job.api.util.TestValueGenerator; +import com.tencent.bk.job.api.v3.constants.APIV3Urls; +import com.tencent.bk.job.api.v3.model.EsbFileSourceSimpleInfoV3DTO; +import com.tencent.bk.job.api.v3.model.request.EsbCreateOrUpdateFileSourceV3Req; +import com.tencent.bk.job.api.v3.model.request.EsbGetFileSourceDetailV3Req; +import io.restassured.common.mapper.TypeRef; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Nested; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static io.restassured.RestAssured.given; +import static org.hamcrest.Matchers.equalTo; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.notNullValue; + +/** + * 文件源 API 测试 + */ +@DisplayName("v3.FileSourceResourceAPITest") +class FileSourceResourceAPITest extends BaseTest { + + private static final List createdFileSourceList = new ArrayList<>(); + + @Nested + class FileSourceCreateTest { + @Test + @DisplayName("测试文件源正常创建") + void testCreateFileSource() { + EsbCreateOrUpdateFileSourceV3Req req = new EsbCreateOrUpdateFileSourceV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setCode(TestValueGenerator.generateUniqueStrValue("file_source_code", 50)); + req.setAlias(TestValueGenerator.generateUniqueStrValue("file_source_alias", 50)); + req.setType(FileSourceTypeEnum.BLUEKING_ARTIFACTORY.name()); + Map accessParams = new HashMap<>(); + accessParams.put("base_url", "https://bkrepo.com"); + req.setAccessParams(accessParams); + req.setCredentialId(TestValueGenerator.generateUniqueStrValue("credential_id", 50)); + EsbFileSourceSimpleInfoV3DTO createdFileSource = + given() + .spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", greaterThan(0)) + .extract() + .body() + .as(new TypeRef>() { + }) + .getData(); + createdFileSource.setCode(req.getCode()); + createdFileSourceList.add(createdFileSource); + } + + @Test + @DisplayName("异常创建文件源测试-比如参数校验不通过") + void givenInvalidCreateFileSourceParamThenFail() { + EsbCreateOrUpdateFileSourceV3Req req = new EsbCreateOrUpdateFileSourceV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setCode(TestValueGenerator.generateUniqueStrValue("file_source_code", 50)); + req.setAlias(TestValueGenerator.generateUniqueStrValue("file_source_alias", 50)); + req.setType(FileSourceTypeEnum.BLUEKING_ARTIFACTORY.name()); + Map accessParams = new HashMap<>(); + accessParams.put("base_url", "https://bkrepo.com"); + req.setAccessParams(accessParams); + req.setCredentialId(TestValueGenerator.generateUniqueStrValue("credential_id", 50)); + + req.setCode(null); + // code为空,创建失败 + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.MISSING_PARAM_WITH_PARAM_NAME)); + + req.setCode("file_source_code_?<"); + // code有非法字符,创建失败 + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.BAD_REQUEST)); + + req.setCode(TestValueGenerator.generateUniqueStrValue("file_source_code", 50)); + // 别名为空,创建失败 + req.setAlias(null); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.MISSING_PARAM_WITH_PARAM_NAME)); + + // 别名有非法字符,创建失败 + req.setAlias("alias|*"); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.BAD_REQUEST)); + + // 类型为空,创建失败 + req.setAlias(TestValueGenerator.generateUniqueStrValue("file_source_alias", 50)); + req.setType(null); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.CREATE_FILE_SOURCE) + .then() + .spec(ApiUtil.failResponseSpec(ErrorCode.ILLEGAL_PARAM_WITH_PARAM_NAME)); + } + } + + @Nested + class FileSourceGetTest { + @Test + @DisplayName("测试查询文件源-通过code查询详情") + void testGetFileSourceDetail() { + EsbFileSourceSimpleInfoV3DTO fileSourceSimpleInfoV3DTO = Operations.createFileSource(); + createdFileSourceList.add(fileSourceSimpleInfoV3DTO); + EsbGetFileSourceDetailV3Req req = new EsbGetFileSourceDetailV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setCode(fileSourceSimpleInfoV3DTO.getCode()); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.GET_FILE_SOURCE_DETAIL) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", greaterThan(0)) + .body("data.code", equalTo(req.getCode())) + .body("data.alias", notNullValue()) + .body("data.file_source_type", notNullValue()) + .body("data.is_public", notNullValue()) + .body("data.credential_id", notNullValue()) + .body("data.enable", notNullValue()) + .body("data.bk_scope_type", equalTo(req.getScopeType())) + .body("data.bk_scope_id", equalTo(req.getScopeId())) + .body("data.creator", notNullValue()) + .body("data.create_time", greaterThan(0L)) + .body("data.last_modify_user", equalTo(TestProps.DEFAULT_TEST_USER)) + .body("data.last_modify_time", greaterThan(0L)); + } + } + + @Nested + class FileSourceUpdateTest { + // 更新操作 + @Test + @DisplayName("测试文件源修改") + void testUpdateFileSource() { + EsbFileSourceSimpleInfoV3DTO fileSourceSimpleInfoV3DTO = Operations.createFileSource(); + createdFileSourceList.add(fileSourceSimpleInfoV3DTO); + EsbCreateOrUpdateFileSourceV3Req req = new EsbCreateOrUpdateFileSourceV3Req(); + req.setScopeId(String.valueOf(TestProps.DEFAULT_BIZ)); + req.setScopeType(ResourceScopeTypeEnum.BIZ.getValue()); + req.setCode(fileSourceSimpleInfoV3DTO.getCode()); + req.setAlias(TestValueGenerator.generateUniqueStrValue("update_file_source_alias", 50)); + given().spec(ApiUtil.requestSpec(TestProps.DEFAULT_TEST_USER)) + .body(JsonUtil.toJson(req)) + .post(APIV3Urls.UPDATE_FILE_SOURCE) + .then() + .spec(ApiUtil.successResponseSpec()) + .body("data", notNullValue()) + .body("data.id", equalTo(fileSourceSimpleInfoV3DTO.getId())); + } + } +} From ff632d517e3c8ad3043a0c8777dd7c6f7bfc6108 Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Mon, 8 Apr 2024 21:07:49 +0800 Subject: [PATCH 2/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=96=87=E4=BB=B6=E6=BA=90=E4=B8=8E=E5=87=AD=E8=AF=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=9A=84ApiGW=E6=8E=A5=E5=8F=A3=20#2830?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../v3/zh/get_credential_detail.md | 12 +-- .../v3/zh/get_file_source_detail.md | 16 ++-- .../apidocs/en/get_credential_detail.md | 79 ----------------- .../apidocs/en/get_file_source_detail.md | 87 ------------------- .../apidocs/zh_hans/create_credential.md | 18 ++-- .../apidocs/zh_hans/create_file_source.md | 2 +- .../apidocs/zh_hans/get_credential_detail.md | 78 ----------------- .../apidocs/zh_hans/get_file_source_detail.md | 86 ------------------ .../apidocs/zh_hans/update_credential.md | 20 ++--- .../apidocs/zh_hans/update_file_source.md | 2 +- docs/apidoc/esb/jobv3-confapis/job.yaml | 26 +----- .../v3/EsbFastTransferFileV3ResourceImpl.java | 6 +- .../api/inner/ServiceFileSourceResource.java | 3 +- .../model/resp/esb/v3/EsbFileSourceV3DTO.java | 10 +-- .../api/esb/EsbFileSourceV3ResourceImpl.java | 2 +- .../inner/ServiceFileSourceResourceImpl.java | 4 +- .../dao/filesource/FileSourceDAO.java | 2 +- .../filesource/impl/FileSourceDAOImpl.java | 9 +- .../file_gateway/model/dto/FileSourceDTO.java | 4 +- .../service/CredentialService.java | 2 +- .../service/FileSourceService.java | 2 +- .../service/impl/FileSourceServiceImpl.java | 4 +- .../bk/job/file/worker/model/req/BaseReq.java | 2 +- .../api/esb/v3/EsbCredentialV3Resource.java | 6 +- .../api/inner/ServiceCredentialResource.java | 4 +- .../manage/api/web/WebCredentialResource.java | 12 +-- .../EsbCreateOrUpdateCredentialV3Req.java | 8 +- .../request/EsbGetCredentialDetailV3Req.java | 4 +- .../inner/resp/ServiceBasicCredentialDTO.java | 2 +- .../inner/resp/ServiceCredentialDTO.java | 6 +- .../resp/ServiceCredentialDisplayDTO.java | 2 +- .../request/CredentialCreateUpdateReq.java | 6 +- .../model/web/vo/CredentialBasicVO.java | 2 +- .../job/manage/model/web/vo/CredentialVO.java | 2 +- .../manage/dao/impl/CredentialDAOImpl.java | 4 +- .../bkiam/0007_bk_job_20210925-1000_iam.json | 2 +- .../bkiam/0008_bk_job_20220218-1000_iam.json | 2 +- ...ile_gateway_20201214-1000_V3.2.0_mysql.sql | 2 +- .../v3/model/EsbFileSourceDetailV3DTO.java | 10 +-- .../EsbCreateOrUpdateCredentialV3Req.java | 8 +- .../request/EsbGetCredentialDetailV3Req.java | 2 +- .../testcase/FileSourceResourceAPITest.java | 2 +- versionLogs/zh_CN/V3.8.4_2023-11-10.md | 6 +- 43 files changed, 109 insertions(+), 459 deletions(-) delete mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md delete mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md delete mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md delete mode 100644 docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md diff --git a/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md b/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md index dcf38897f3..249aa62f9c 100644 --- a/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md +++ b/docs/apidoc/bk-api-gateway/v3/zh/get_credential_detail.md @@ -21,13 +21,13 @@ | bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | | bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | | bk_biz_id | long | 是 | *已弃用*。业务ID。此字段已被弃用并由字段bk_scope_type+bk_scope_id替换 | -| id | String | 是 | 凭据ID | +| id | String | 是 | 凭证ID | ### 请求参数示例 - GET ```json -/api/v3/get_credential_detail?bk_scope_type=biz&bk_scope_id=1&id=xxx +/api/v3/get_credential_detail?bk_scope_type=biz&bk_scope_id=2&id=xxx ``` ### 返回结果示例 @@ -47,7 +47,7 @@ "creator": "admin", "create_time": 1712049204719, "last_modify_user": "admin", - "last_modify_time": "1712049204719" + "last_modify_time": 1712049204719 } } ``` @@ -67,11 +67,11 @@ | ---------------- | ------ | ------------------------------------------------------------ | | bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | | bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| id | string | 凭据ID | +| id | string | 凭证ID | | name | string | 凭证名称 | | type | string | 类型。可选值:APP_ID_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY| | description | string | 描述 | | creator | string | 作业创建人账号 | -| create_time | long | 创建时间,Unix 时间戳 | +| create_time | long | 创建时间,Unix时间戳(ms) | | last_modify_user | string | 作业修改人账号 | -| last_modify_time | long | 最后修改时间,Unix 时间戳 | +| last_modify_time | long | 最后修改时间,Unix时间戳(ms) | diff --git a/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md b/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md index ba9b4e4e16..bedc7baffe 100644 --- a/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md +++ b/docs/apidoc/bk-api-gateway/v3/zh/get_file_source_detail.md @@ -27,7 +27,7 @@ - GET ```json -/api/v3/get_file_source_detail?bk_scope_type=biz&bk_scope_id=1&code=1 +/api/v3/get_file_source_detail?bk_scope_type=biz&bk_scope_id=2&code=bkrepo-1 ``` ### 返回结果示例 @@ -40,11 +40,11 @@ "data": { "bk_scope_type": "biz", "bk_scope_id": "2", - "id": 0, - "code": "xxx", + "id": 10001, + "code": "bkrepo-1", "alias": "xxx", "status": 0, - "file_source_type": 3, + "file_source_type_code": "BLUEKING_ARTIFACTORY", "is_public": false, "credential_id": "xxx", "enable": true, @@ -75,11 +75,11 @@ | code | string | 文件源code | | alias | string | 文件源别名 | | status | int | 状态 | -| file_source_type | int | 类型。可选值:蓝鲸制品库 | +| file_source_type_code | string | 文件源类型code。可选值:BLUEKING_ARTIFACTORY | | is_public | bool | 是否为公用文件源 | -| credential_id | string | 凭据ID | +| credential_id | string | 凭证ID | | enable | bool | 是否启用 | | creator | string | 作业创建人账号 | -| create_time | long | 创建时间,Unix 时间戳 | +| create_time | long | 创建时间,Unix时间戳(ms) | | last_modify_user | string | 作业修改人账号 | -| last_modify_time | long | 最后修改时间,Unix 时间戳 | +| last_modify_time | long | 最后修改时间,Unix时间戳(ms) | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md deleted file mode 100644 index d89a489fc8..0000000000 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_credential_detail.md +++ /dev/null @@ -1,79 +0,0 @@ -### Function Description - -Query credential details - -### Request Parameters - -{{ common_args_desc }} - -#### Interface parameters - -| Fields | Type | Required | Description | -| ------------- | ------ | ---- | ------------------------------------------------------- | -| bk_scope_type | string | yes | Resource scope type. Optional values: biz - Business,biz_set - Business Set | -| bk_scope_id | string | yes | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | -| id | String | yes | Credential ID | - -### Example of request - -```json -{ - "bk_app_code": "esb_test", - "bk_app_secret": "xxx", - "bk_token": "xxx", - "bk_scope_type": "biz", - "bk_scope_id": "1", - "id": "xxx" -} -``` - -### Example of responses - -```json -{ - "result": true, - "code": 0, - "message": "", - "data": { - "bk_scope_type": "biz", - "bk_scope_id": "2", - "id": "xxx", - "name": "xxx", - "type": "xxx", - "description": "xxx", - "creator": "admin", - "create_time": 1712049204719, - "last_modify_user": "admin", - "last_modify_time": "1712049204719" - } -} -``` - -### Response Description - -#### response - -| Fields | Type | Description | -|-----------|-----------|-----------| -| result | bool | Whether the request was successful or not. True: request succeeded;False: request failed| -| code | int | Error code. 0 indicates success, >0 indicates failure| -| message | string |Error message| -| data | object |Data returned by request| -| permission | object |Permission information| -| request_id | string |Request chain id| - - -#### data - -| Fields | Type | Description | -| ---------------- | ------ | ------------------------------------------------------------ | -| bk_scope_type | string | Resource scope type. Optional values: biz - Business,biz_set - Business Set | -| bk_scope_id | string | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | -| id | string | Credential ID | -| name | string | Credential name | -| type | string | Type. Optional values:APP_ID_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY| -| description | string | Description | -| creator | string | Creator | -| create_time | long | Creation time Unix timestamp (ms) | -| last_modify_user | string | Last modify user | -| last_modify_time | long | Last modified time Unix timestamp (ms) | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md deleted file mode 100644 index 016d1728ff..0000000000 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/en/get_file_source_detail.md +++ /dev/null @@ -1,87 +0,0 @@ -### Function Description - -Query file source details - -### Request Parameters - -{{ common_args_desc }} - -#### Interface parameters - -| Fields | Type | Required | Description | -| ------------- | ------ | ---- | ------------------------------------------------------- | -| bk_scope_type | string | yes | Resource scope type. Optional values: biz - Business,biz_set - Business Set | -| bk_scope_id | string | yes | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | -| code | String | yes | File source code | - -### Example of request - -```json -{ - "bk_app_code": "esb_test", - "bk_app_secret": "xxx", - "bk_token": "xxx", - "bk_scope_type": "biz", - "bk_scope_id": "1", - "code": "xxx" -} -``` - -### Example of responses - -```json -{ - "result": true, - "code": 0, - "message": "", - "data": { - "bk_scope_type": "biz", - "bk_scope_id": "2", - "id": 0, - "code": "xxx", - "alias": "xxx", - "status": 0, - "file_source_type": 3, - "is_public": false, - "credential_id": "xxx", - "enable": true, - "creator": "admin", - "create_time": 1712050614742, - "last_modify_user": "admin", - "last_modify_time": 1712050614742 - } -} -``` - -### Response Description - -#### response - -| Fields | Type | Description | -|-----------|-----------|-----------| -| result | bool | Whether the request was successful or not. True: request succeeded;False: request failed| -| code | int | Error code. 0 indicates success, >0 indicates failure| -| message | string |Error message| -| data | object |Data returned by request| -| permission | object |Permission information| -| request_id | string |Request chain id| - - -#### data - -| Fields | Type | Description | -| ---------------- | ------ | ------------------------------------------------------------ | -| bk_scope_type | string | Resource scope type. Optional values: biz - Business,biz_set - Business Set | -| bk_scope_id | string | Resource scope ID. Corresponds to bk_scope_type, which means business ID or business set ID | -| id | int | File source ID | -| code | string | File source code | -| alias | string | File source alias | -| status | int | Status | -| file_source_type | int | File source type.Optional values: blueking artifactory | -| is_public | bool | Is it a public file source | -| credential_id | string | Credential ID | -| enable | bool | Enable | -| creator | string | Creator | -| create_time | long | Creation time Unix timestamp (ms) | -| last_modify_user | string | Last modify user | -| last_modify_time | long | Last modified time Unix timestamp (ms) | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_credential.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_credential.md index 61a2e8d86f..b24aa2010b 100644 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_credential.md +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_credential.md @@ -1,6 +1,6 @@ ### 功能描述 -新建凭据。 +新建凭证。 ### 请求参数 @@ -12,13 +12,13 @@ |----------------------------|------------|--------|------------| | bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | | bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| name | string | 是 | 凭据名称 | -| type | string | 是 | 凭据类型,取值可为ACCESS_KEY_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY | -| description | string | 否 | 凭据描述 | -| credential_access_key | string | 否 | 凭据类型为ACCESS_KEY_SECRET_KEY时填写 | -| credential_secret_key | string | 否 | 凭据类型为ACCESS_KEY_SECRET_KEY/SECRET_KEY时填写 | -| credential_username | string | 否 | 凭据类型为USERNAME_PASSWORD时填写 | -| credential_password | string | 否 | 凭据类型为USERNAME_PASSWORD/PASSWORD时填写 | +| name | string | 是 | 凭证名称 | +| type | string | 是 | 凭证类型,取值可为ACCESS_KEY_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY | +| description | string | 否 | 凭证描述 | +| credential_access_key | string | 否 | 凭证类型为ACCESS_KEY_SECRET_KEY时填写 | +| credential_secret_key | string | 否 | 凭证类型为ACCESS_KEY_SECRET_KEY/SECRET_KEY时填写 | +| credential_username | string | 否 | 凭证类型为USERNAME_PASSWORD时填写 | +| credential_password | string | 否 | 凭证类型为USERNAME_PASSWORD/PASSWORD时填写 | ### 请求参数示例 @@ -67,4 +67,4 @@ | 字段 | 类型 |字段是否一定存在 | 描述 | |-----------|-------|---------------|---------| -| id | string |是 | 凭据ID | +| id | string |是 | 凭证ID | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_file_source.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_file_source.md index 7e9da62c9f..f2a7d0f1cc 100644 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_file_source.md +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/create_file_source.md @@ -25,7 +25,7 @@ | alias | string | 是 | 文件源别名 | | type | string | 是 | 文件源类型,当前仅支持蓝鲸制品库,BLUEKING_ARTIFACTORY | | access_params | object | 是 | 文件源接入参数,根据type传入不同的对象,见后续说明 | -| credential_id | string | 否 | 文件源使用的凭据Id | +| credential_id | string | 否 | 文件源使用的凭证Id | | file_prefix | string | 否 | Job对从该文件源分发的文件加上的前缀,不传默认不加前缀 | ### access_params diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md deleted file mode 100644 index 6b93c72db9..0000000000 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_credential_detail.md +++ /dev/null @@ -1,78 +0,0 @@ -### 功能描述 - -查询凭证详情 - -### 请求参数 - -{{ common_args_desc }} - -#### 接口参数 - -| 字段 | 类型 | 必选 | 描述 | -| ------------- | ------ | ---- | ------------------------------------------------------- | -| bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | -| bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| id | String | 是 | 凭据ID | - -### 请求参数示例 - -```json -{ - "bk_app_code": "esb_test", - "bk_app_secret": "xxx", - "bk_token": "xxx", - "bk_scope_type": "biz", - "bk_scope_id": "1", - "id": "xxx" -} -``` - -### 返回结果示例 - -```json -{ - "result": true, - "code": 0, - "message": "", - "data": { - "bk_scope_type": "biz", - "bk_scope_id": "2", - "id": "xxx", - "name": "xxx", - "type": "xxx", - "description": "xxx", - "creator": "admin", - "create_time": 1712049204719, - "last_modify_user": "admin", - "last_modify_time": "1712049204719" - } -} -``` - -### 返回结果参数说明 - -#### response - -| 字段 | 类型 | 描述 | -| ---------- | ------ | ------------------------------------------ | -| result | bool | 请求成功与否。true:请求成功;false请求失败 | -| code | int | 错误编码。 0表示success,>0表示失败错误 | -| message | string | 请求失败返回的错误信息 | -| data | object | 请求返回的数据 | -| permission | object | 权限信息 | - - -#### data - -| 字段 | 类型 | 描述 | -| ---------------- | ------ | ------------------------------------------------------------ | -| bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | -| bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| id | string | 凭据ID | -| name | string | 凭证名称 | -| type | string | 类型。可选值:APP_ID_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY| -| description | string | 描述 | -| creator | string | 作业创建人账号 | -| create_time | long | 创建时间,Unix 时间戳 | -| last_modify_user | string | 作业修改人账号 | -| last_modify_time | long | 最后修改时间,Unix 时间戳 | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md deleted file mode 100644 index 32e0061e8a..0000000000 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/get_file_source_detail.md +++ /dev/null @@ -1,86 +0,0 @@ -### 功能描述 - -查询文件源详情 - -### 请求参数 - -{{ common_args_desc }} - -#### 接口参数 - -| 字段 | 类型 | 必选 | 描述 | -| ------------- | ------ | ---- | ------------------------------------------------------- | -| bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | -| bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| code | String | 是 | 文件源code | - -### 请求参数示例 - -```json -{ - "bk_app_code": "esb_test", - "bk_app_secret": "xxx", - "bk_token": "xxx", - "bk_scope_type": "biz", - "bk_scope_id": "1", - "code": "xxx" -} -``` - -### 返回结果示例 - -```json -{ - "result": true, - "code": 0, - "message": "", - "data": { - "bk_scope_type": "biz", - "bk_scope_id": "2", - "id": 0, - "code": "xxx", - "alias": "xxx", - "status": 0, - "file_source_type": 3, - "is_public": false, - "credential_id": "xxx", - "enable": true, - "creator": "admin", - "create_time": 1712050614742, - "last_modify_user": "admin", - "last_modify_time": 1712050614742 - } -} -``` - -### 返回结果参数说明 - -#### response - -| 字段 | 类型 | 描述 | -| ---------- | ------ | ------------------------------------------ | -| result | bool | 请求成功与否。true:请求成功;false请求失败 | -| code | int | 错误编码。 0表示success,>0表示失败错误 | -| message | string | 请求失败返回的错误信息 | -| data | object | 请求返回的数据 | -| permission | object | 权限信息 | - - -#### data - -| 字段 | 类型 | 描述 | -| ---------------- | ------ | ------------------------------------------------------------ | -| bk_scope_type | string | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | -| bk_scope_id | string | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| id | int | 文件源ID | -| code | string | 文件源code | -| alias | string | 文件源别名 | -| status | int | 状态 | -| file_source_type | int | 类型。可选值:蓝鲸制品库 | -| is_public | bool | 是否为公用文件源 | -| credential_id | string | 凭据ID | -| enable | bool | 是否启用 | -| creator | string | 作业创建人账号 | -| create_time | long | 创建时间,Unix 时间戳 | -| last_modify_user | string | 作业修改人账号 | -| last_modify_time | long | 最后修改时间,Unix 时间戳 | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_credential.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_credential.md index 2753b91447..12e27ac57a 100644 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_credential.md +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_credential.md @@ -1,6 +1,6 @@ ### 功能描述 -更新凭据。 +更新凭证。 ### 请求参数 @@ -12,14 +12,14 @@ |----------------------------|------------|--------|------------| | bk_scope_type | string | 是 | 资源范围类型。可选值: biz - 业务,biz_set - 业务集 | | bk_scope_id | string | 是 | 资源范围ID, 与bk_scope_type对应, 表示业务ID或者业务集ID | -| id | string | 是 | 凭据 ID | -| name | string | 否 | 凭据名称 | -| type | string | 否 | 凭据类型,取值可为ACCESS_KEY_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY | -| description | string | 否 | 凭据描述 | -| credential_access_key | string | 否 | 凭据类型为ACCESS_KEY_SECRET_KEY时填写 | -| credential_secret_key | string | 否 | 凭据类型为ACCESS_KEY_SECRET_KEY/SECRET_KEY时填写 | -| credential_username | string | 否 | 凭据类型为USERNAME_PASSWORD时填写 | -| credential_password | string | 否 | 凭据类型为USERNAME_PASSWORD/PASSWORD时填写 | +| id | string | 是 | 凭证 ID | +| name | string | 否 | 凭证名称 | +| type | string | 否 | 凭证类型,取值可为ACCESS_KEY_SECRET_KEY,PASSWORD,USERNAME_PASSWORD,SECRET_KEY | +| description | string | 否 | 凭证描述 | +| credential_access_key | string | 否 | 凭证类型为ACCESS_KEY_SECRET_KEY时填写 | +| credential_secret_key | string | 否 | 凭证类型为ACCESS_KEY_SECRET_KEY/SECRET_KEY时填写 | +| credential_username | string | 否 | 凭证类型为USERNAME_PASSWORD时填写 | +| credential_password | string | 否 | 凭证类型为USERNAME_PASSWORD/PASSWORD时填写 | ### 请求参数示例 @@ -69,4 +69,4 @@ | 字段 | 类型 |字段是否一定存在 | 描述 | |-----------|-------|---------------|---------| -| id | string |是 | 凭据ID | +| id | string |是 | 凭证ID | diff --git a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_file_source.md b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_file_source.md index e65e5ee99d..43e2c0c6da 100644 --- a/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_file_source.md +++ b/docs/apidoc/esb/jobv3-confapis/apidocs/zh_hans/update_file_source.md @@ -16,7 +16,7 @@ | alias | string | 否 | 文件源别名 | | type | string | 否 | 文件源类型,当前仅支持蓝鲸制品库,BLUEKING_ARTIFACTORY | | access_params | object | 否 | 文件源接入参数,根据type传入不同的对象,见后续说明 | -| credential_id | string | 否 | 文件源使用的凭据Id | +| credential_id | string | 否 | 文件源使用的凭证Id | | file_prefix | string | 否 | Job对从该文件源分发的文件加上的前缀,不传默认不加前缀 | ### access_params diff --git a/docs/apidoc/esb/jobv3-confapis/job.yaml b/docs/apidoc/esb/jobv3-confapis/job.yaml index 31ceb15363..d877135e4f 100644 --- a/docs/apidoc/esb/jobv3-confapis/job.yaml +++ b/docs/apidoc/esb/jobv3-confapis/job.yaml @@ -271,7 +271,7 @@ - path: /v2/jobv3/create_credential/ name: create_credential - label: 新建凭据 + label: 新建凭证 label_en: Create credential suggest_method: POST api_type: operate @@ -282,7 +282,7 @@ - path: /v2/jobv3/update_credential/ name: update_credential - label: 更新凭据 + label: 更新凭证 label_en: Update credential suggest_method: POST api_type: operate @@ -291,17 +291,6 @@ dest_http_method: POST is_hidden: True -- path: /v2/jobv3/get_credential_detail/ - name: get_credential_detail - label: 查询凭据详情 - label_en: get credential detail - suggest_method: POST - api_type: query - comp_codename: generic.v2.jobv3.job_component - dest_path: /api/job/v3/job-manage/get_credential_detail/ - dest_http_method: POST - is_hidden: True - - path: /v2/jobv3/create_file_source/ name: create_file_source label: 新建文件源 @@ -324,17 +313,6 @@ dest_http_method: POST is_hidden: True -- path: /v2/jobv3/get_file_source_detail/ - name: get_file_source_detail - label: 查询文件源详情 - label_en: get file source detail - suggest_method: POST - api_type: query - comp_codename: generic.v2.jobv3.job_component - dest_path: /api/job/v3/job-file-gateway/get_file_source_detail/ - dest_http_method: POST - is_hidden: True - - path: /v2/jobv3/generate_local_file_upload_url/ name: generate_local_file_upload_url label: 生成本地文件上传URL diff --git a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbFastTransferFileV3ResourceImpl.java b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbFastTransferFileV3ResourceImpl.java index f80b0bae6a..e6518da92f 100644 --- a/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbFastTransferFileV3ResourceImpl.java +++ b/src/backend/job-execute/service-job-execute/src/main/java/com/tencent/bk/job/execute/api/esb/v3/EsbFastTransferFileV3ResourceImpl.java @@ -251,7 +251,7 @@ private StepInstanceDTO buildFastFileStepInstance(String username, stepInstance.setExecuteType(StepExecuteTypeEnum.SEND_FILE); stepInstance.setFileTargetPath(request.getTargetPath()); stepInstance.setFileTargetName(request.getTargetName()); - stepInstance.setFileSourceList(convertFileSource(request.getFileSources())); + stepInstance.setFileSourceList(convertFileSource(request.getAppId(), request.getFileSources())); stepInstance.setAppId(request.getAppId()); stepInstance.setTargetExecuteObjects(convertToServersDTO(request.getTargetServer())); stepInstance.setOperator(username); @@ -277,7 +277,7 @@ private StepInstanceDTO buildFastFileStepInstance(String username, return stepInstance; } - private List convertFileSource(List fileSources) throws ServiceException { + private List convertFileSource(Long appId, List fileSources) throws ServiceException { if (fileSources == null) { return null; } @@ -318,7 +318,7 @@ private List convertFileSource(List fileSourc fileSourceDTO.setFileSourceId(fileSource.getFileSourceId()); } else if (StringUtils.isNotBlank(fileSourceCode)) { try { - InternalResponse resp = fileSourceResource.getFileSourceIdByCode(fileSourceCode); + InternalResponse resp = fileSourceResource.getFileSourceIdByCode(appId, fileSourceCode); if (resp != null && resp.isSuccess()) { if (resp.getData() != null) { fileSourceDTO.setFileSourceId(resp.getData()); diff --git a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java index d7f9e48e43..dc7cb46f1a 100644 --- a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java +++ b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java @@ -39,8 +39,9 @@ public interface ServiceFileSourceResource { @ApiOperation(value = "获取文件源ID", produces = "application/json") - @GetMapping("/service/fileSource/getFileSourceIdByCode/codes/{code}") + @GetMapping("/service/app/{appId}/fileSource/getFileSourceIdByCode/codes/{code}") InternalResponse getFileSourceIdByCode( + @ApiParam(value = "Job业务ID", required = true) @PathVariable("appId") Long appId, @ApiParam(value = "文件源标识", required = true) @PathVariable("code") String code); @ApiOperation(value = "判断是否存在文件源引用了指定凭证", produces = "application/json") diff --git a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java index 3a8cff9846..31f17585a8 100644 --- a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java +++ b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/resp/esb/v3/EsbFileSourceV3DTO.java @@ -57,11 +57,11 @@ public class EsbFileSourceV3DTO extends EsbAppScopeDTO { @JsonPropertyDescription("File source status") private Integer status; /** - * 类型 + * 文件源类型code */ - @JsonProperty("file_source_type") - @JsonPropertyDescription("File source type") - private Integer fileSourceType; + @JsonProperty("file_source_type_code") + @JsonPropertyDescription("File source type code") + private String fileSourceTypeCode; /** * 是否为公共文件源 @@ -71,7 +71,7 @@ public class EsbFileSourceV3DTO extends EsbAppScopeDTO { private boolean publicFlag; /** - * 凭据Id + * 凭证Id */ @JsonPropertyDescription("File source credential id") @JsonProperty("credential_id") diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java index ed7344f856..184954e022 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/esb/EsbFileSourceV3ResourceImpl.java @@ -96,7 +96,7 @@ public EsbResp getFileSourceDetailUsingPost( String username, String appCode, @AuditRequestBody EsbGetFileSourceDetailV3Req req) { - FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(req.getCode()); + FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(req.getAppId(), req.getCode()); return EsbResp.buildSuccessResp(FileSourceDTO.toEsbFileSourceV3DTO(fileSourceDTO)); } diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java index 4aaac4f7d8..35593dda6b 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java @@ -46,8 +46,8 @@ public ServiceFileSourceResourceImpl(FileSourceService fileSourceService) { } @Override - public InternalResponse getFileSourceIdByCode(String code) { - FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(code); + public InternalResponse getFileSourceIdByCode(Long appId, String code) { + FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(appId, code); if (null == fileSourceDTO) { throw new NotFoundException(ErrorCode.FAIL_TO_FIND_FILE_SOURCE_BY_CODE, new String[]{code}); } diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java index 976f2cb10a..deff0566e5 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java @@ -45,7 +45,7 @@ public interface FileSourceDAO { List listFileSourceByIds(Collection ids); - FileSourceDTO getFileSourceByCode(String code); + FileSourceDTO getFileSourceByCode(Long appId, String code); Integer countAvailableLikeFileSource(Long appId, String credentialId, String alias); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java index d740366be6..955e6b4596 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java @@ -312,10 +312,11 @@ public List listFileSourceByIds(Collection ids) } @Override - public FileSourceDTO getFileSourceByCode(String code) { - val record = dslContext.selectFrom(defaultTable).where( - defaultTable.CODE.eq(code) - ).fetchOne(); + public FileSourceDTO getFileSourceByCode(Long appId, String code) { + val record = dslContext.selectFrom(defaultTable) + .where(defaultTable.CODE.eq(code)) + .and(defaultTable.APP_ID.eq(appId)) + .fetchOne(); if (record == null) { return null; } else { diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/dto/FileSourceDTO.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/dto/FileSourceDTO.java index 0c5b1d19d3..6b1d2e8f2b 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/dto/FileSourceDTO.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/model/dto/FileSourceDTO.java @@ -92,7 +92,7 @@ public class FileSourceDTO { */ private Boolean shareToAllApp; /** - * 凭据Id + * 凭证Id */ private String credentialId; /** @@ -165,7 +165,7 @@ public static EsbFileSourceV3DTO toEsbFileSourceV3DTO(FileSourceDTO fileSourceDT fileSource.setAlias(fileSourceDTO.getAlias()); fileSource.setCredentialId(fileSourceDTO.getCredentialId()); fileSource.setEnable(fileSourceDTO.getEnable()); - fileSource.setFileSourceType(fileSourceDTO.getFileSourceType().getId()); + fileSource.setFileSourceTypeCode(fileSourceDTO.getFileSourceType().getCode()); fileSource.setPublicFlag(fileSourceDTO.getPublicFlag()); fileSource.setStatus(fileSourceDTO.getStatus()); fileSource.setCreateTime(fileSourceDTO.getCreateTime()); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/CredentialService.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/CredentialService.java index 5dd296a433..93acbc6ad3 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/CredentialService.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/CredentialService.java @@ -29,7 +29,7 @@ public interface CredentialService { /** - * 获取凭据 + * 获取凭证 * * @param id * @return diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java index e059972f16..8b33fafcb8 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java @@ -90,7 +90,7 @@ List listWorkTableFileSource( List listFileSourceByIds(Collection ids); - FileSourceDTO getFileSourceByCode(String code); + FileSourceDTO getFileSourceByCode(Long appId, String code); List getFileSourceParams(Long appId, String fileSourceTypeCode); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java index ab54ae2f3a..69e1e92c47 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java @@ -309,8 +309,8 @@ public List listFileSourceByIds(Collection ids) } @Override - public FileSourceDTO getFileSourceByCode(String code) { - return fileSourceDAO.getFileSourceByCode(code); + public FileSourceDTO getFileSourceByCode(Long appId, String code) { + return fileSourceDAO.getFileSourceByCode(appId, code); } private Long chooseAvailableWorker(String fileSourceTypeCode) { diff --git a/src/backend/job-file-worker-sdk/api-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/model/req/BaseReq.java b/src/backend/job-file-worker-sdk/api-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/model/req/BaseReq.java index c4604013a1..fc18e84ffd 100644 --- a/src/backend/job-file-worker-sdk/api-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/model/req/BaseReq.java +++ b/src/backend/job-file-worker-sdk/api-job-file-worker-sdk/src/main/java/com/tencent/bk/job/file/worker/model/req/BaseReq.java @@ -38,7 +38,7 @@ public class BaseReq { // 文件源类型编码 String fileSourceTypeCode; - // 凭据信息 + // 凭证信息 @SkipLogFields CommonCredential credential; diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java index d3ad0a0be6..38f01c9fb8 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/esb/v3/EsbCredentialV3Resource.java @@ -41,7 +41,7 @@ import org.springframework.web.bind.annotation.RestController; /** - * 凭据API-V3 + * 凭证API-V3 */ @RequestMapping("/esb/api/v3") @RestController @@ -76,10 +76,10 @@ EsbResp getCredentialDetail( @RequestParam(value = "id") String id); /** - * 获取凭据详情 + * 获取凭证详情 * * @param req 查询请求 - * @return 凭据详情 + * @return 凭证详情 */ @PostMapping("/get_credential_detail") EsbResp getCredentialDetailUsingPost( diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/ServiceCredentialResource.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/ServiceCredentialResource.java index 8ffce9cb58..dc056cd55b 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/ServiceCredentialResource.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/inner/ServiceCredentialResource.java @@ -39,12 +39,12 @@ @InternalAPI public interface ServiceCredentialResource { - @ApiOperation(value = "获取凭据详情", produces = "application/json") + @ApiOperation(value = "获取凭证详情", produces = "application/json") @GetMapping("/service/credentials/app/{appId}/ids/{id}") InternalResponse getCredentialById( @ApiParam(value = "业务ID", required = true) @PathVariable("appId") Long appId, - @ApiParam("凭据ID") + @ApiParam("凭证ID") @PathVariable("id") String id ); diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebCredentialResource.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebCredentialResource.java index 828f6472a1..82b5a471b6 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebCredentialResource.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/api/web/WebCredentialResource.java @@ -53,7 +53,7 @@ @WebAPI public interface WebCredentialResource { - @ApiOperation(value = "获取凭据列表", produces = "application/json") + @ApiOperation(value = "获取凭证列表", produces = "application/json") @GetMapping("/list") Response> listCredentials( @ApiParam("用户名,网关自动传入") @@ -91,7 +91,7 @@ Response> listCredentials( Integer pageSize ); - @ApiOperation(value = "分页获取凭据基础信息", produces = "application/json") + @ApiOperation(value = "分页获取凭证基础信息", produces = "application/json") @GetMapping("/basicInfo/list") Response> listCredentialBasicInfo( @ApiParam("用户名,网关自动传入") @@ -115,7 +115,7 @@ Response> listCredentialBasicInfo( ); - @ApiOperation(value = "新增凭据", produces = "application/json") + @ApiOperation(value = "新增凭证", produces = "application/json") @PostMapping Response createCredential( @ApiParam(value = "用户名,网关自动传入", required = true) @@ -135,7 +135,7 @@ Response createCredential( CredentialCreateUpdateReq createUpdateReq ); - @ApiOperation(value = "更新凭据", produces = "application/json") + @ApiOperation(value = "更新凭证", produces = "application/json") @PutMapping("/{credentialId}") Response updateCredential( @ApiParam(value = "用户名,网关自动传入", required = true) @@ -159,7 +159,7 @@ Response updateCredential( ); - @ApiOperation(value = "删除凭据", produces = "application/json") + @ApiOperation(value = "删除凭证", produces = "application/json") @DeleteMapping("/ids/{id}") Response deleteCredentialById( @ApiParam("用户名,网关自动传入") @@ -174,7 +174,7 @@ Response deleteCredentialById( @ApiParam(value = "资源范围ID", required = true) @PathVariable(value = "scopeId") String scopeId, - @ApiParam("凭据ID") + @ApiParam("凭证ID") @PathVariable("id") String id ); diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbCreateOrUpdateCredentialV3Req.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbCreateOrUpdateCredentialV3Req.java index 478324649d..5853f769af 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbCreateOrUpdateCredentialV3Req.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbCreateOrUpdateCredentialV3Req.java @@ -30,24 +30,24 @@ import lombok.EqualsAndHashCode; /** - * 新建凭据请求 + * 新建凭证请求 */ @EqualsAndHashCode(callSuper = true) @Data public class EsbCreateOrUpdateCredentialV3Req extends EsbAppScopeReq { /** - * 凭据ID + * 凭证ID */ private String id; /** - * 凭据名称 + * 凭证名称 */ private String name; /** - * 凭据类型 + * 凭证类型 */ private String type; diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java index 338306e6ca..b8069035a4 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/esb/v3/request/EsbGetCredentialDetailV3Req.java @@ -11,9 +11,9 @@ public class EsbGetCredentialDetailV3Req extends EsbAppScopeReq { /** - * 凭据id + * 凭证id */ - @ApiModelProperty(value = "凭据id") + @ApiModelProperty(value = "凭证id") @NotBlankField(fieldName = "id") private String id; } diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceBasicCredentialDTO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceBasicCredentialDTO.java index 14e794c26a..f1011c912f 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceBasicCredentialDTO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceBasicCredentialDTO.java @@ -30,7 +30,7 @@ import lombok.Data; import lombok.NoArgsConstructor; -@ApiModel("凭据基本信息") +@ApiModel("凭证基本信息") @Data @AllArgsConstructor @NoArgsConstructor diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDTO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDTO.java index b5e782d06f..7bea9cf96b 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDTO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDTO.java @@ -29,7 +29,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; -@ApiModel("凭据") +@ApiModel("凭证") @Data public class ServiceCredentialDTO { /** @@ -53,8 +53,8 @@ public class ServiceCredentialDTO { @ApiModelProperty("类型") private String type; /** - * 凭据 + * 凭证 */ - @ApiModelProperty("凭据") + @ApiModelProperty("凭证") private CommonCredential credential; } diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDisplayDTO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDisplayDTO.java index e0d14539e0..0848b1b1fc 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDisplayDTO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/inner/resp/ServiceCredentialDisplayDTO.java @@ -29,7 +29,7 @@ import lombok.AllArgsConstructor; import lombok.Data; -@ApiModel("凭据") +@ApiModel("凭证") @AllArgsConstructor @Data public class ServiceCredentialDisplayDTO { diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/CredentialCreateUpdateReq.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/CredentialCreateUpdateReq.java index ab246116c1..a85f063f73 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/CredentialCreateUpdateReq.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/request/CredentialCreateUpdateReq.java @@ -36,13 +36,13 @@ import static com.tencent.bk.job.manage.api.common.constants.CredentialTypeEnum.USERNAME_PASSWORD; @Data -@ApiModel("凭据创建/更新请求") +@ApiModel("凭证创建/更新请求") public class CredentialCreateUpdateReq { /** - * 凭据ID + * 凭证ID */ - @ApiModelProperty(value = "凭据 ID", hidden = true) + @ApiModelProperty(value = "凭证 ID", hidden = true) private String id; /** * 名称 diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialBasicVO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialBasicVO.java index ffdb666ec6..7e86735736 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialBasicVO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialBasicVO.java @@ -28,7 +28,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; -@ApiModel("凭据") +@ApiModel("凭证") @Data public class CredentialBasicVO { /** diff --git a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialVO.java b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialVO.java index de79504482..d019c20600 100644 --- a/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialVO.java +++ b/src/backend/job-manage/api-job-manage/src/main/java/com/tencent/bk/job/manage/model/web/vo/CredentialVO.java @@ -30,7 +30,7 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; -@ApiModel("凭据") +@ApiModel("凭证") @Data public class CredentialVO { /** diff --git a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/CredentialDAOImpl.java b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/CredentialDAOImpl.java index 452c0d5ff9..718035d4c2 100644 --- a/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/CredentialDAOImpl.java +++ b/src/backend/job-manage/service-job-manage/src/main/java/com/tencent/bk/job/manage/dao/impl/CredentialDAOImpl.java @@ -206,7 +206,7 @@ private List buildConditionList( } /** - * 查询符合条件的凭据数量 + * 查询符合条件的凭证数量 */ private long getPageCredentialCount(CredentialDTO credentialQuery, BaseSearchCondition baseSearchCondition) { List conditions = buildConditionList(credentialQuery, baseSearchCondition); @@ -214,7 +214,7 @@ private long getPageCredentialCount(CredentialDTO credentialQuery, BaseSearchCon } /** - * 查询符合条件的凭据数量 + * 查询符合条件的凭证数量 */ private long getPageCredentialCount(Collection conditions) { Long count = dslContext diff --git a/support-files/bkiam/0007_bk_job_20210925-1000_iam.json b/support-files/bkiam/0007_bk_job_20210925-1000_iam.json index 37421f438a..6e80f33aa3 100644 --- a/support-files/bkiam/0007_bk_job_20210925-1000_iam.json +++ b/support-files/bkiam/0007_bk_job_20210925-1000_iam.json @@ -132,7 +132,7 @@ "id": "ticket", "name": "凭证", "name_en": "Tickets", - "description": "用于文件源访问认证的凭据", + "description": "用于文件源访问认证的凭证", "description_en": "Tickets for file-source access authentication", "parents": [ { diff --git a/support-files/bkiam/0008_bk_job_20220218-1000_iam.json b/support-files/bkiam/0008_bk_job_20220218-1000_iam.json index 941019a64a..6adf01acc9 100644 --- a/support-files/bkiam/0008_bk_job_20220218-1000_iam.json +++ b/support-files/bkiam/0008_bk_job_20220218-1000_iam.json @@ -171,7 +171,7 @@ "id": "ticket", "name": "凭证", "name_en": "Tickets", - "description": "用于文件源访问认证的凭据", + "description": "用于文件源访问认证的凭证", "description_en": "Tickets for file-source access authentication", "parents": [ { diff --git a/support-files/sql/job-file-gateway/0001_job_file_gateway_20201214-1000_V3.2.0_mysql.sql b/support-files/sql/job-file-gateway/0001_job_file_gateway_20201214-1000_V3.2.0_mysql.sql index 33f53aff6e..6582736e91 100644 --- a/support-files/sql/job-file-gateway/0001_job_file_gateway_20201214-1000_V3.2.0_mysql.sql +++ b/support-files/sql/job-file-gateway/0001_job_file_gateway_20201214-1000_V3.2.0_mysql.sql @@ -18,7 +18,7 @@ CREATE TABLE IF NOT EXISTS `file_source` ( `custom_info` text CHARACTER SET utf8mb4 NULL COMMENT '各不同文件源的差异性自定义信息Json串', `public` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否为公共存储', `share_to_all_app` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否共享至全业务', - `credential_id` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '凭据Id', + `credential_id` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '凭证Id', `file_prefix` varchar(255) CHARACTER SET utf8mb4 NULL DEFAULT NULL COMMENT '文件前缀名', `worker_select_scope` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'ALL' COMMENT '接入点选择范畴:APP/PUBLIC/ALL', `worker_select_mode` varchar(255) CHARACTER SET utf8mb4 NOT NULL DEFAULT 'AUTO' COMMENT '接入点选择模式:AUTO/MANUAL', diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java index 871389e7c1..80064adc02 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/EsbFileSourceDetailV3DTO.java @@ -56,11 +56,11 @@ public class EsbFileSourceDetailV3DTO extends EsbAppScopeDTO { @JsonPropertyDescription("File source status") private Integer status; /** - * 类型 + * 文件源类型code */ - @JsonProperty("file_source_type") - @JsonPropertyDescription("File source type") - private Integer fileSourceType; + @JsonProperty("file_source_type_code") + @JsonPropertyDescription("File source type code") + private Integer fileSourceTypeCode; /** * 是否为公共文件源 @@ -70,7 +70,7 @@ public class EsbFileSourceDetailV3DTO extends EsbAppScopeDTO { private boolean publicFlag; /** - * 凭据Id + * 凭证Id */ @JsonPropertyDescription("File source credential id") @JsonProperty("credential_id") diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java index f6ae270231..a6b5cda923 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbCreateOrUpdateCredentialV3Req.java @@ -30,24 +30,24 @@ import lombok.EqualsAndHashCode; /** - * 新建凭据请求 + * 新建凭证请求 */ @EqualsAndHashCode(callSuper = true) @Data public class EsbCreateOrUpdateCredentialV3Req extends EsbAppScopeReq { /** - * 凭据ID + * 凭证ID */ private String id; /** - * 凭据名称 + * 凭证名称 */ private String name; /** - * 凭据类型 + * 凭证类型 */ private String type; diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java index 480442bd67..9658dce63e 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/model/request/EsbGetCredentialDetailV3Req.java @@ -9,7 +9,7 @@ public class EsbGetCredentialDetailV3Req extends EsbAppScopeReq { /** - * 凭据id + * 凭证id */ private String id; } diff --git a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java index 3ac56789b1..c1fb5753ea 100644 --- a/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java +++ b/tests/openapi/src/test/java/com/tencent/bk/job/api/v3/testcase/FileSourceResourceAPITest.java @@ -147,7 +147,7 @@ void testGetFileSourceDetail() { .body("data.id", greaterThan(0)) .body("data.code", equalTo(req.getCode())) .body("data.alias", notNullValue()) - .body("data.file_source_type", notNullValue()) + .body("data.file_source_type_code", notNullValue()) .body("data.is_public", notNullValue()) .body("data.credential_id", notNullValue()) .body("data.enable", notNullValue()) diff --git a/versionLogs/zh_CN/V3.8.4_2023-11-10.md b/versionLogs/zh_CN/V3.8.4_2023-11-10.md index 1949097afe..283a7211ef 100644 --- a/versionLogs/zh_CN/V3.8.4_2023-11-10.md +++ b/versionLogs/zh_CN/V3.8.4_2023-11-10.md @@ -6,10 +6,10 @@ - [ 修复 ] 解决 IP选择器输入重复IP会报错的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2591) - [ 修复 ] 修复凭证表单字段校验提示错位问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2588) -- [ 修复 ] 解决各字段输入空格符也可成功创建凭据的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2587) +- [ 修复 ] 解决各字段输入空格符也可成功创建凭证的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2587) - [ 修复 ] 补全国际化相关缺漏 [详情](http://github.com/TencentBlueKing/bk-job/issues/2585) - [ 修复 ] 解决当主机类型全局变量为空时,查看任务的全局变量详情可能出现请求内部异常的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2583) -- [ 修复 ] 解决文件源引用的凭据在编辑表单页没有正常回显的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2576) +- [ 修复 ] 解决文件源引用的凭证在编辑表单页没有正常回显的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2576) - [ 修复 ] 解决文件源引用的凭证无法选取到列表第一页后面数据的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2579) - [ 修复 ] 解决执行历史详情页的表格字段显示设置在只有一个字段时,呼出的窗口会突破浏览器边界导致无法看全的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2574) - [ 修复 ] 修复作业模版调试操作没有正常生成审计事件问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2557) @@ -20,4 +20,4 @@ - [ 修复 ] 修复编辑文件源报 404 错误问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2554) - [ 修复 ] 解决因执行详情任务名称过长导致样式错乱的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2545) - [ 修复 ] 解决审计中心回调 Job 获取资源实例的 schema 报错问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2541) -- [ 修复 ] 解决权限中心回调作业平台API 请求脚本列表报错的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2540) \ No newline at end of file +- [ 修复 ] 解决权限中心回调作业平台API 请求脚本列表报错的问题 [详情](http://github.com/TencentBlueKing/bk-job/issues/2540) From b07d11eaad9966425f6e9a1ed85f3b31e3389b74 Mon Sep 17 00:00:00 2001 From: liuliaozhong Date: Tue, 9 Apr 2024 10:50:10 +0800 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E6=96=87=E4=BB=B6=E6=BA=90=E4=B8=8E=E5=87=AD=E8=AF=81?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E7=9A=84ApiGW=E6=8E=A5=E5=8F=A3=20#2830?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/inner/ServiceFileSourceResource.java | 10 ++++++++++ .../api/inner/ServiceFileSourceResourceImpl.java | 9 +++++++++ .../file_gateway/dao/filesource/FileSourceDAO.java | 7 +++++++ .../dao/filesource/impl/FileSourceDAOImpl.java | 12 ++++++++++++ .../job/file_gateway/service/FileSourceService.java | 7 +++++++ .../service/impl/FileSourceServiceImpl.java | 5 +++++ 6 files changed, 50 insertions(+) diff --git a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java index dc7cb46f1a..0b8546984a 100644 --- a/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java +++ b/src/backend/job-file-gateway/api-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResource.java @@ -24,7 +24,9 @@ package com.tencent.bk.job.file_gateway.api.inner; +import com.tencent.bk.job.common.annotation.CompatibleImplementation; import com.tencent.bk.job.common.annotation.InternalAPI; +import com.tencent.bk.job.common.constant.CompatibleType; import com.tencent.bk.job.common.model.InternalResponse; import com.tentent.bk.job.common.api.feign.annotation.SmartFeignClient; import io.swagger.annotations.Api; @@ -44,6 +46,14 @@ InternalResponse getFileSourceIdByCode( @ApiParam(value = "Job业务ID", required = true) @PathVariable("appId") Long appId, @ApiParam(value = "文件源标识", required = true) @PathVariable("code") String code); + @Deprecated + @CompatibleImplementation(name = "fileSourceId", deprecatedVersion = "3.9.x", type = CompatibleType.DEPLOY, + explain = "文件源标识仅在appId下唯一,发布完成后可删除") + @ApiOperation(value = "获取文件源ID", produces = "application/json") + @GetMapping("/service/fileSource/getFileSourceIdByCode/codes/{code}") + InternalResponse getFileSourceIdByCode( + @ApiParam(value = "文件源标识", required = true) @PathVariable("code") String code); + @ApiOperation(value = "判断是否存在文件源引用了指定凭证", produces = "application/json") @GetMapping("/service/app/{appId}/fileSource/existsFileSourceUsingCredential/credentialIds/{credentialId}") InternalResponse existsFileSourceUsingCredential( diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java index 35593dda6b..e62d319fab 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/api/inner/ServiceFileSourceResourceImpl.java @@ -54,6 +54,15 @@ public InternalResponse getFileSourceIdByCode(Long appId, String code) return InternalResponse.buildSuccessResp(fileSourceDTO.getId()); } + @Override + public InternalResponse getFileSourceIdByCode(String code) { + FileSourceDTO fileSourceDTO = fileSourceService.getFileSourceByCode(code); + if (null == fileSourceDTO) { + throw new NotFoundException(ErrorCode.FAIL_TO_FIND_FILE_SOURCE_BY_CODE, new String[]{code}); + } + return InternalResponse.buildSuccessResp(fileSourceDTO.getId()); + } + @Override public InternalResponse existsFileSourceUsingCredential(Long appId, String credentialId) { boolean result = fileSourceService.existsFileSourceUsingCredential(appId, credentialId); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java index deff0566e5..5807ba2e99 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/FileSourceDAO.java @@ -24,6 +24,8 @@ package com.tencent.bk.job.file_gateway.dao.filesource; +import com.tencent.bk.job.common.annotation.CompatibleImplementation; +import com.tencent.bk.job.common.constant.CompatibleType; import com.tencent.bk.job.file_gateway.model.dto.FileSourceBasicInfoDTO; import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO; @@ -45,6 +47,11 @@ public interface FileSourceDAO { List listFileSourceByIds(Collection ids); + @Deprecated + @CompatibleImplementation(name = "fileSourceId", deprecatedVersion = "3.9.x", type = CompatibleType.DEPLOY, + explain = "文件源标识仅在appId下唯一,发布完成后可删除") + FileSourceDTO getFileSourceByCode(String code); + FileSourceDTO getFileSourceByCode(Long appId, String code); Integer countAvailableLikeFileSource(Long appId, String credentialId, String alias); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java index 955e6b4596..4d265f5b79 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/dao/filesource/impl/FileSourceDAOImpl.java @@ -311,6 +311,18 @@ public List listFileSourceByIds(Collection ids) return records.map(this::convertRecordToBasicInfoDto); } + @Override + public FileSourceDTO getFileSourceByCode(String code) { + val record = dslContext.selectFrom(defaultTable) + .where(defaultTable.CODE.eq(code)) + .fetchOne(); + if (record == null) { + return null; + } else { + return convertRecordToDto(record); + } + } + @Override public FileSourceDTO getFileSourceByCode(Long appId, String code) { val record = dslContext.selectFrom(defaultTable) diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java index 8b33fafcb8..9135d578e7 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/FileSourceService.java @@ -24,6 +24,8 @@ package com.tencent.bk.job.file_gateway.service; +import com.tencent.bk.job.common.annotation.CompatibleImplementation; +import com.tencent.bk.job.common.constant.CompatibleType; import com.tencent.bk.job.file_gateway.model.dto.FileSourceBasicInfoDTO; import com.tencent.bk.job.file_gateway.model.dto.FileSourceDTO; import com.tencent.bk.job.file_gateway.model.dto.FileSourceTypeDTO; @@ -90,6 +92,11 @@ List listWorkTableFileSource( List listFileSourceByIds(Collection ids); + @Deprecated + @CompatibleImplementation(name = "fileSourceId", deprecatedVersion = "3.9.x", type = CompatibleType.DEPLOY, + explain = "文件源标识仅在appId下唯一,发布完成后可删除") + FileSourceDTO getFileSourceByCode(String code); + FileSourceDTO getFileSourceByCode(Long appId, String code); List getFileSourceParams(Long appId, String fileSourceTypeCode); diff --git a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java index 69e1e92c47..49d94ec7a6 100644 --- a/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java +++ b/src/backend/job-file-gateway/service-job-file-gateway/src/main/java/com/tencent/bk/job/file_gateway/service/impl/FileSourceServiceImpl.java @@ -308,6 +308,11 @@ public List listFileSourceByIds(Collection ids) return fileSourceDAO.listFileSourceByIds(ids); } + @Override + public FileSourceDTO getFileSourceByCode(String code) { + return fileSourceDAO.getFileSourceByCode(code); + } + @Override public FileSourceDTO getFileSourceByCode(Long appId, String code) { return fileSourceDAO.getFileSourceByCode(appId, code);