16 Commits

Author SHA1 Message Date
longjuan
97f653bd42 feat: support selecting groups to join when link (#165)
fixes https://github.com/halo-dev/plugin-s3/issues/152
```release-note
S3关联时支持选择加入的分组
```
![image](https://github.com/user-attachments/assets/2380688c-3e04-4485-986d-b9118e05fe95)
2024-07-31 04:40:03 +00:00
longjuan
d4df735759 perf: refactor API request implementation and upgrade Halo dependency to 2.17 (#163)
使用 openapi-generator 重构请求库
使用 @halo-dev/api-client 提供的axiosInstance
提升所有 Halo 依赖版本至2.17
```release-note
None
```
2024-07-14 15:27:27 +00:00
longjuan
63be3ed3dc chore: bump version to 1.11.0 (#164)
```release-note
None
```
2024-07-14 15:25:26 +00:00
guqing
40f66ff665 chore: remove deprecated plugin wrapper (#161)
### What this PR does?
移除对已过时的 PluginWrapper 的引用,Halo 2.18.0 版本后将不在支持从 BasePlugin 中获取 PluginWrapper ,也不再支持依赖注入 PluginWrapper,使用 PluginContext 代替

see also https://github.com/halo-dev/halo/pull/6243 for more details

```release-note
None
```
2024-07-02 15:29:25 +00:00
longjuan
cb968de154 fix: apply natural ordering to policy and attachment listings (#160)
```release-note
None
```
传递unsorted以支持Halo 2.17版本
2024-07-02 15:27:25 +00:00
longjuan
bdd62cbe12 faet: Add file prefix search function in s3link (#153)
```release-note
在 S3关联 中支持文件名前缀搜索
```
fixes https://github.com/halo-dev/plugin-s3/issues/142
2024-06-16 12:30:45 +00:00
longjuan
2a26171fc4 Fix: Correct policy selector styling issue (#151)
```release-note
修复 S3 关联中策略选择器太短的问题
```
fixes #141
2024-05-14 02:08:33 +00:00
longjuan
6b62ce7aa4 Hide the permission of the verification interface (#147)
fixes https://github.com/halo-dev/plugin-s3/issues/146
```release-note
在角色创建中隐藏配置校验接口的权限
```
2024-05-06 10:34:54 +00:00
Ryan Wang
c60e31a033 chore: update plugin.yaml file (#138)
完善插件定义文件。

1. 将 homepage 字段指向 Halo 应用市场的地址。
2. 新增 repo 字段指向源码仓库地址。
3. 新增 issues 字段指向 GitHub issues 地址。

```release-note
None
```
2024-05-05 08:39:33 +00:00
Chenhe
7a9b0de0c6 improve usage tips in settings page (#140)
使用占位组件在设置页面展示信息并不恰当,并且此项目作为存储插件的 Example 工程易误导其他开发者。

调整为利用 FormKit `el` 特性实现。

问题背景:https://github.com/halo-dev/halo/issues/5802

**Preview - old**
<img width="373" alt="image" src="https://github.com/halo-dev/plugin-s3/assets/10266066/ac4aaede-6377-459f-a866-9bfe132906af">

**Preview - new**
<img width="373" alt="image" src="https://github.com/halo-dev/plugin-s3/assets/10266066/f884417c-045a-4396-84be-633d18ae36c9">

```release-note
优化调整提示的提示
```
2024-04-28 11:54:48 +00:00
longjuan
5e7e6620fd chore: bump version to 1.9.0 (#135)
```release-note
None
```
2024-04-22 06:08:08 +00:00
longjuan
47b6a37d0a feat: add verification function to the configuration of s3 object storage policy (#134)
```release-note
在 S3 存储策略配置中增加了验证配置的功能。
```
fixes https://github.com/halo-dev/plugin-s3/issues/132
2024-04-22 04:26:10 +00:00
longjuan
68b1a88b14 Fix original file name being incorrectly replaced (#129) 2024-04-14 20:25:05 +08:00
longjuan
f4ec56b7bc perf: optimize s3link interfaces using index mechanisms (#127)
* perf: optimize s3link list queries using index mechanisms
2024-04-03 12:10:54 +08:00
John Niang
c5d4e719a7 Simplify GitHub workflow by using reusable workflow (#130) 2024-03-26 22:11:52 +08:00
Ryan Wang
034b3f3ded chore: rename displayName to S3 对象存储 (#128)
在 Halo 完成动态数据的 i18n 之前,使用中文描述存储策略名称。

/kind improvement

<img width="821" alt="image" src="https://github.com/halo-dev/plugin-s3/assets/21301288/bc5fd32c-f7fc-43de-8bc4-cdbdd7e940d6">

```release-note
修改存储策略名称为中文显示。
```
2024-03-24 11:54:08 +00:00
80 changed files with 6620 additions and 3230 deletions

17
.github/workflows/cd.yaml vendored Normal file
View File

@@ -0,0 +1,17 @@
name: CD
on:
release:
types:
- published
jobs:
cd:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-cd.yaml@v1
secrets:
halo-username: ${{ secrets.HALO_USERNAME }}
halo-password: ${{ secrets.HALO_PASSWORD }}
permissions:
contents: write
with:
app-id: app-Qxhpp

13
.github/workflows/ci.yaml vendored Normal file
View File

@@ -0,0 +1,13 @@
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
ci:
uses: halo-sigs/reusable-workflows/.github/workflows/plugin-ci.yaml@v1

View File

@@ -1,138 +0,0 @@
name: Build Plugin JAR File
on:
push:
branches:
- main
paths:
- "**"
- "!**.md"
release:
types:
- published
pull_request:
branches:
- main
paths:
- "**"
- "!**.md"
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'temurin'
cache: 'gradle'
java-version: 17
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 18
- uses: pnpm/action-setup@v2.0.1
name: Install pnpm
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
run: |
echo "::set-output name=pnpm_cache_dir::$(pnpm store path)"
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/widget/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install Frontend Dependencies
run: |
./gradlew pnpmInstall
- name: Build with Gradle
run: |
# Set the version with tag name when releasing
version=${{ github.event.release.tag_name }}
version=${version#v}
sed -i "s/version=.*-SNAPSHOT$/version=$version/1" gradle.properties
./gradlew clean build -x test
- name: Archive plugin-s3 jar
uses: actions/upload-artifact@v2
with:
name: plugin-s3
path: |
build/libs/*.jar
retention-days: 1
github-release:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
steps:
- name: Download plugin-s3 jar
uses: actions/download-artifact@v2
with:
name: plugin-s3
path: build/libs
- name: Get Name of Artifact
id: get_artifact
run: |
ARTIFACT_PATHNAME=$(ls build/libs/*.jar | head -n 1)
ARTIFACT_NAME=$(basename ${ARTIFACT_PATHNAME})
echo "Artifact pathname: ${ARTIFACT_PATHNAME}"
echo "Artifact name: ${ARTIFACT_NAME}"
echo "ARTIFACT_PATHNAME=${ARTIFACT_PATHNAME}" >> $GITHUB_ENV
echo "ARTIFACT_NAME=${ARTIFACT_NAME}" >> $GITHUB_ENV
echo "RELEASE_ID=${{ github.event.release.id }}" >> $GITHUB_ENV
- name: Upload a Release Asset
uses: actions/github-script@v2
if: github.event_name == 'release'
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
console.log('environment', process.versions);
const fs = require('fs').promises;
const { repo: { owner, repo }, sha } = context;
console.log({ owner, repo, sha });
const releaseId = process.env.RELEASE_ID
const artifactPathName = process.env.ARTIFACT_PATHNAME
const artifactName = process.env.ARTIFACT_NAME
console.log('Releasing', releaseId, artifactPathName, artifactName)
await github.repos.uploadReleaseAsset({
owner, repo,
release_id: releaseId,
name: artifactName,
data: await fs.readFile(artifactPathName)
});
app-store-release:
runs-on: ubuntu-latest
needs: build
if: github.event_name == 'release'
steps:
- uses: actions/checkout@v3
with:
submodules: true
- name: Download plugin-s3 jar
uses: actions/download-artifact@v2
with:
name: plugin-s3
path: build/libs
- name: Sync to Halo App Store
uses: halo-sigs/app-store-release-action@main
with:
github-token: ${{secrets.GITHUB_TOKEN}}
app-id: ${{secrets.APP_ID}}
release-id: ${{ github.event.release.id }}
assets-dir: "build/libs"
halo-username: ${{ secrets.HALO_USERNAME }}
halo-password: ${{ secrets.HALO_PASSWORD }}

View File

@@ -2,11 +2,15 @@ plugins {
id 'java'
id "com.github.node-gradle.node" version "5.0.0"
id "io.freefair.lombok" version "8.0.1"
id "run.halo.plugin.devtools" version "0.0.7"
id "run.halo.plugin.devtools" version "0.0.9"
id 'org.openapi.generator' version '7.7.0'
}
group 'run.halo.s3os'
sourceCompatibility = JavaVersion.VERSION_17
java {
sourceCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
@@ -16,7 +20,7 @@ repositories {
}
dependencies {
implementation platform('run.halo.tools.platform:plugin:2.12.0-SNAPSHOT')
implementation platform('run.halo.tools.platform:plugin:2.17.0-SNAPSHOT')
compileOnly 'run.halo.app:api'
implementation platform('software.amazon.awssdk:bom:2.19.8')
@@ -36,7 +40,7 @@ configurations.runtimeClasspath {
halo {
version = '2.12.1'
version = '2.17.0'
}
haloPlugin {
@@ -59,7 +63,37 @@ task buildFrontend(type: PnpmTask) {
args = ['build']
}
tasks.named('buildFrontend') {
dependsOn 'pnpmInstall'
}
build {
// build frontend before build
tasks.getByName('compileJava').dependsOn('buildFrontend')
}
task downloadOpenApiSpec {
doLast {
def url = 'http://localhost:8090/v3/api-docs/plugin-s3'
def file = layout.buildDirectory.dir("apidocs/openapi.json").get().asFile
file.parentFile.mkdirs()
file.text = new URL(url).text
}
}
openApiGenerate {
generatorName = "typescript-axios"
inputSpec = layout.buildDirectory.dir("apidocs/openapi.json").get().asFile.getAbsolutePath()
outputDir = "${projectDir}/console/src/api"
additionalProperties = [
useES6: true,
useSingleRequestParameter: true,
withSeparateModelsAndApi: true,
apiPackage: "api",
modelPackage: "models"
]
typeMappings = [
set: "Array"
]
}

View File

@@ -1,5 +1,5 @@
{
"name": "@halo-dev/plugin-starter",
"name": "@halo-dev/plugin-s3",
"version": "1.0.0",
"private": true,
"scripts": {
@@ -11,38 +11,40 @@
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore"
},
"dependencies": {
"@halo-dev/api-client": "^2.11.0",
"@halo-dev/components": "^1.10.0",
"@halo-dev/console-shared": "^2.11.0",
"@halo-dev/api-client": "^2.17.0",
"@halo-dev/components": "^2.17.0",
"@halo-dev/console-shared": "^2.17.0",
"@tanstack/vue-query": "4.29.1",
"axios": "^1.4.0",
"axios": "^1.7.2",
"canvas-confetti": "^1.6.0",
"path-browserify": "^1.0.1",
"vue": "^3.3.4"
"vue": "^3.4.27"
},
"devDependencies": {
"@halo-dev/ui-plugin-bundler-kit": "^2.12.0",
"@halo-dev/ui-plugin-bundler-kit": "^2.17.0",
"@iconify/json": "^2.2.18",
"@rushstack/eslint-patch": "^1.2.0",
"@tsconfig/node18": "^18.2.4",
"@types/canvas-confetti": "^1.6.0",
"@types/jsdom": "^20.0.0",
"@types/node": "^16.18.0",
"@vitejs/plugin-vue": "^3.1.2",
"@vitejs/plugin-vue-jsx": "^2.0.1",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^11.0.2",
"@vue/test-utils": "^2.2.0",
"@vue/tsconfig": "^0.1.3",
"eslint": "^8.26.0",
"eslint-plugin-vue": "^9.6.0",
"jsdom": "^19.0.0",
"@types/node": "^18.11.19",
"@vitejs/plugin-vue": "^5.0.4",
"@vitejs/plugin-vue-jsx": "^3.1.0",
"@vue/eslint-config-prettier": "^7.1.0",
"@vue/eslint-config-typescript": "^11.0.3",
"@vue/test-utils": "^2.4.6",
"@vue/tsconfig": "^0.5.1",
"eslint": "^8.43.0",
"eslint-plugin-vue": "^9.17.0",
"jsdom": "^20.0.3",
"npm-run-all": "^4.1.5",
"prettier": "^2.7.1",
"prettier": "^2.8.8",
"sass": "^1.58.0",
"typescript": "~4.7.4",
"typescript": "~5.3.0",
"unplugin-icons": "^0.15.2",
"vite": "^3.1.8",
"vitest": "^0.24.3",
"vue-tsc": "^1.0.9"
"vite": "^5.0.0",
"vitest": "^0.34.1",
"vue-router": "^4.4.0",
"vue-tsc": "^1.8.27"
}
}

6348
console/pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

4
console/src/api/.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
wwwroot/*.js
node_modules
typings
dist

View File

@@ -0,0 +1 @@
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm

View File

@@ -0,0 +1,25 @@
# OpenAPI Generator Ignore
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
# Use this file to prevent files from being overwritten by the generator.
# The patterns follow closely to .gitignore or .dockerignore.
# As an example, the C# client generator defines ApiClient.cs.
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
#ApiClient.cs
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
#foo/*/qux
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
#foo/**/qux
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
# You can also negate patterns with an exclamation (!).
# For example, you can ignore all files in a docs folder with the file extension .md:
#docs/*.md
# Then explicitly reverse the ignore rule for a single file:
#!docs/README.md
git_push.sh

View File

@@ -0,0 +1,31 @@
.gitignore
.npmignore
api.ts
api/policy-config-validation-controller-api.ts
api/s3-link-controller-api.ts
api/s3-unlink-controller-api.ts
base.ts
common.ts
configuration.ts
index.ts
models/add-operation.ts
models/attachment-spec.ts
models/attachment-status.ts
models/attachment.ts
models/copy-operation.ts
models/index.ts
models/json-patch-inner.ts
models/link-request.ts
models/link-result-item.ts
models/link-result.ts
models/metadata.ts
models/move-operation.ts
models/object-vo.ts
models/policy-spec.ts
models/policy.ts
models/remove-operation.ts
models/replace-operation.ts
models/s3-list-result.ts
models/s3-os-properties.ts
models/test-operation.ts
models/url-suffix-item.ts

View File

@@ -0,0 +1 @@
7.7.0

20
console/src/api/api.ts Normal file
View File

@@ -0,0 +1,20 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from './api/policy-config-validation-controller-api';
export * from './api/s3-link-controller-api';
export * from './api/s3-unlink-controller-api';

View File

@@ -0,0 +1,151 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { S3OsProperties } from '../models';
/**
* PolicyConfigValidationControllerApi - axios parameter creator
* @export
*/
export const PolicyConfigValidationControllerApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @param {S3OsProperties} s3OsProperties
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
validatePolicyConfig: async (s3OsProperties: S3OsProperties, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 's3OsProperties' is not null or undefined
assertParamExists('validatePolicyConfig', 's3OsProperties', s3OsProperties)
const localVarPath = `/apis/s3os.halo.run/v1alpha1/policies/s3/validation`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication basicAuth required
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)
// authentication bearerAuth required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(s3OsProperties, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* PolicyConfigValidationControllerApi - functional programming interface
* @export
*/
export const PolicyConfigValidationControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = PolicyConfigValidationControllerApiAxiosParamCreator(configuration)
return {
/**
*
* @param {S3OsProperties} s3OsProperties
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async validatePolicyConfig(s3OsProperties: S3OsProperties, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.validatePolicyConfig(s3OsProperties, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['PolicyConfigValidationControllerApi.validatePolicyConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* PolicyConfigValidationControllerApi - factory interface
* @export
*/
export const PolicyConfigValidationControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = PolicyConfigValidationControllerApiFp(configuration)
return {
/**
*
* @param {PolicyConfigValidationControllerApiValidatePolicyConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
validatePolicyConfig(requestParameters: PolicyConfigValidationControllerApiValidatePolicyConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
return localVarFp.validatePolicyConfig(requestParameters.s3OsProperties, options).then((request) => request(axios, basePath));
},
};
};
/**
* Request parameters for validatePolicyConfig operation in PolicyConfigValidationControllerApi.
* @export
* @interface PolicyConfigValidationControllerApiValidatePolicyConfigRequest
*/
export interface PolicyConfigValidationControllerApiValidatePolicyConfigRequest {
/**
*
* @type {S3OsProperties}
* @memberof PolicyConfigValidationControllerApiValidatePolicyConfig
*/
readonly s3OsProperties: S3OsProperties
}
/**
* PolicyConfigValidationControllerApi - object-oriented interface
* @export
* @class PolicyConfigValidationControllerApi
* @extends {BaseAPI}
*/
export class PolicyConfigValidationControllerApi extends BaseAPI {
/**
*
* @param {PolicyConfigValidationControllerApiValidatePolicyConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PolicyConfigValidationControllerApi
*/
public validatePolicyConfig(requestParameters: PolicyConfigValidationControllerApiValidatePolicyConfigRequest, options?: RawAxiosRequestConfig) {
return PolicyConfigValidationControllerApiFp(this.configuration).validatePolicyConfig(requestParameters.s3OsProperties, options).then((request) => request(this.axios, this.basePath));
}
}

View File

@@ -0,0 +1,377 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { LinkRequest } from '../models';
// @ts-ignore
import type { LinkResult } from '../models';
// @ts-ignore
import type { Policy } from '../models';
// @ts-ignore
import type { S3ListResult } from '../models';
/**
* S3LinkControllerApi - axios parameter creator
* @export
*/
export const S3LinkControllerApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @param {LinkRequest} linkRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
addAttachmentRecord: async (linkRequest: LinkRequest, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'linkRequest' is not null or undefined
assertParamExists('addAttachmentRecord', 'linkRequest', linkRequest)
const localVarPath = `/apis/s3os.halo.run/v1alpha1/attachments/link`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication basicAuth required
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)
// authentication bearerAuth required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
localVarHeaderParameter['Content-Type'] = 'application/json';
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(linkRequest, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {string} policyName
* @param {number} pageSize
* @param {string} [continuationToken]
* @param {string} [continuationObject]
* @param {boolean} [unlinked]
* @param {string} [filePrefix]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listObjects: async (policyName: string, pageSize: number, continuationToken?: string, continuationObject?: string, unlinked?: boolean, filePrefix?: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'policyName' is not null or undefined
assertParamExists('listObjects', 'policyName', policyName)
// verify required parameter 'pageSize' is not null or undefined
assertParamExists('listObjects', 'pageSize', pageSize)
const localVarPath = `/apis/s3os.halo.run/v1alpha1/objects/{policyName}`
.replace(`{${"policyName"}}`, encodeURIComponent(String(policyName)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication basicAuth required
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)
// authentication bearerAuth required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
if (continuationToken !== undefined) {
localVarQueryParameter['continuationToken'] = continuationToken;
}
if (continuationObject !== undefined) {
localVarQueryParameter['continuationObject'] = continuationObject;
}
if (pageSize !== undefined) {
localVarQueryParameter['pageSize'] = pageSize;
}
if (unlinked !== undefined) {
localVarQueryParameter['unlinked'] = unlinked;
}
if (filePrefix !== undefined) {
localVarQueryParameter['filePrefix'] = filePrefix;
}
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listS3Policies: async (options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/apis/s3os.halo.run/v1alpha1/policies/s3`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'GET', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication basicAuth required
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)
// authentication bearerAuth required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* S3LinkControllerApi - functional programming interface
* @export
*/
export const S3LinkControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = S3LinkControllerApiAxiosParamCreator(configuration)
return {
/**
*
* @param {LinkRequest} linkRequest
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async addAttachmentRecord(linkRequest: LinkRequest, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<LinkResult>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.addAttachmentRecord(linkRequest, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['S3LinkControllerApi.addAttachmentRecord']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @param {string} policyName
* @param {number} pageSize
* @param {string} [continuationToken]
* @param {string} [continuationObject]
* @param {boolean} [unlinked]
* @param {string} [filePrefix]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listObjects(policyName: string, pageSize: number, continuationToken?: string, continuationObject?: string, unlinked?: boolean, filePrefix?: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<S3ListResult>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listObjects(policyName, pageSize, continuationToken, continuationObject, unlinked, filePrefix, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['S3LinkControllerApi.listObjects']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async listS3Policies(options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Array<Policy>>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.listS3Policies(options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['S3LinkControllerApi.listS3Policies']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* S3LinkControllerApi - factory interface
* @export
*/
export const S3LinkControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = S3LinkControllerApiFp(configuration)
return {
/**
*
* @param {S3LinkControllerApiAddAttachmentRecordRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
addAttachmentRecord(requestParameters: S3LinkControllerApiAddAttachmentRecordRequest, options?: RawAxiosRequestConfig): AxiosPromise<LinkResult> {
return localVarFp.addAttachmentRecord(requestParameters.linkRequest, options).then((request) => request(axios, basePath));
},
/**
*
* @param {S3LinkControllerApiListObjectsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listObjects(requestParameters: S3LinkControllerApiListObjectsRequest, options?: RawAxiosRequestConfig): AxiosPromise<S3ListResult> {
return localVarFp.listObjects(requestParameters.policyName, requestParameters.pageSize, requestParameters.continuationToken, requestParameters.continuationObject, requestParameters.unlinked, requestParameters.filePrefix, options).then((request) => request(axios, basePath));
},
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
listS3Policies(options?: RawAxiosRequestConfig): AxiosPromise<Array<Policy>> {
return localVarFp.listS3Policies(options).then((request) => request(axios, basePath));
},
};
};
/**
* Request parameters for addAttachmentRecord operation in S3LinkControllerApi.
* @export
* @interface S3LinkControllerApiAddAttachmentRecordRequest
*/
export interface S3LinkControllerApiAddAttachmentRecordRequest {
/**
*
* @type {LinkRequest}
* @memberof S3LinkControllerApiAddAttachmentRecord
*/
readonly linkRequest: LinkRequest
}
/**
* Request parameters for listObjects operation in S3LinkControllerApi.
* @export
* @interface S3LinkControllerApiListObjectsRequest
*/
export interface S3LinkControllerApiListObjectsRequest {
/**
*
* @type {string}
* @memberof S3LinkControllerApiListObjects
*/
readonly policyName: string
/**
*
* @type {number}
* @memberof S3LinkControllerApiListObjects
*/
readonly pageSize: number
/**
*
* @type {string}
* @memberof S3LinkControllerApiListObjects
*/
readonly continuationToken?: string
/**
*
* @type {string}
* @memberof S3LinkControllerApiListObjects
*/
readonly continuationObject?: string
/**
*
* @type {boolean}
* @memberof S3LinkControllerApiListObjects
*/
readonly unlinked?: boolean
/**
*
* @type {string}
* @memberof S3LinkControllerApiListObjects
*/
readonly filePrefix?: string
}
/**
* S3LinkControllerApi - object-oriented interface
* @export
* @class S3LinkControllerApi
* @extends {BaseAPI}
*/
export class S3LinkControllerApi extends BaseAPI {
/**
*
* @param {S3LinkControllerApiAddAttachmentRecordRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof S3LinkControllerApi
*/
public addAttachmentRecord(requestParameters: S3LinkControllerApiAddAttachmentRecordRequest, options?: RawAxiosRequestConfig) {
return S3LinkControllerApiFp(this.configuration).addAttachmentRecord(requestParameters.linkRequest, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {S3LinkControllerApiListObjectsRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof S3LinkControllerApi
*/
public listObjects(requestParameters: S3LinkControllerApiListObjectsRequest, options?: RawAxiosRequestConfig) {
return S3LinkControllerApiFp(this.configuration).listObjects(requestParameters.policyName, requestParameters.pageSize, requestParameters.continuationToken, requestParameters.continuationObject, requestParameters.unlinked, requestParameters.filePrefix, options).then((request) => request(this.axios, this.basePath));
}
/**
*
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof S3LinkControllerApi
*/
public listS3Policies(options?: RawAxiosRequestConfig) {
return S3LinkControllerApiFp(this.configuration).listS3Policies(options).then((request) => request(this.axios, this.basePath));
}
}

View File

@@ -0,0 +1,149 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from '../configuration';
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
// Some imports not used depending on template conditions
// @ts-ignore
import { DUMMY_BASE_URL, assertParamExists, setApiKeyToObject, setBasicAuthToObject, setBearerAuthToObject, setOAuthToObject, setSearchParams, serializeDataIfNeeded, toPathString, createRequestFunction } from '../common';
// @ts-ignore
import { BASE_PATH, COLLECTION_FORMATS, type RequestArgs, BaseAPI, RequiredError, operationServerMap } from '../base';
// @ts-ignore
import type { Attachment } from '../models';
/**
* S3UnlinkControllerApi - axios parameter creator
* @export
*/
export const S3UnlinkControllerApiAxiosParamCreator = function (configuration?: Configuration) {
return {
/**
*
* @param {string} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
unlink: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('unlink', 'name', name)
const localVarPath = `/apis/s3os.halo.run/v1alpha1/attachments/{name}`
.replace(`{${"name"}}`, encodeURIComponent(String(name)));
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}
const localVarRequestOptions = { method: 'DELETE', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;
// authentication basicAuth required
// http basic authentication required
setBasicAuthToObject(localVarRequestOptions, configuration)
// authentication bearerAuth required
// http bearer authentication required
await setBearerAuthToObject(localVarHeaderParameter, configuration)
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
}
};
/**
* S3UnlinkControllerApi - functional programming interface
* @export
*/
export const S3UnlinkControllerApiFp = function(configuration?: Configuration) {
const localVarAxiosParamCreator = S3UnlinkControllerApiAxiosParamCreator(configuration)
return {
/**
*
* @param {string} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async unlink(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<Attachment>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.unlink(name, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['S3UnlinkControllerApi.unlink']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
}
};
/**
* S3UnlinkControllerApi - factory interface
* @export
*/
export const S3UnlinkControllerApiFactory = function (configuration?: Configuration, basePath?: string, axios?: AxiosInstance) {
const localVarFp = S3UnlinkControllerApiFp(configuration)
return {
/**
*
* @param {S3UnlinkControllerApiUnlinkRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
unlink(requestParameters: S3UnlinkControllerApiUnlinkRequest, options?: RawAxiosRequestConfig): AxiosPromise<Attachment> {
return localVarFp.unlink(requestParameters.name, options).then((request) => request(axios, basePath));
},
};
};
/**
* Request parameters for unlink operation in S3UnlinkControllerApi.
* @export
* @interface S3UnlinkControllerApiUnlinkRequest
*/
export interface S3UnlinkControllerApiUnlinkRequest {
/**
*
* @type {string}
* @memberof S3UnlinkControllerApiUnlink
*/
readonly name: string
}
/**
* S3UnlinkControllerApi - object-oriented interface
* @export
* @class S3UnlinkControllerApi
* @extends {BaseAPI}
*/
export class S3UnlinkControllerApi extends BaseAPI {
/**
*
* @param {S3UnlinkControllerApiUnlinkRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof S3UnlinkControllerApi
*/
public unlink(requestParameters: S3UnlinkControllerApiUnlinkRequest, options?: RawAxiosRequestConfig) {
return S3UnlinkControllerApiFp(this.configuration).unlink(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
}
}

86
console/src/api/base.ts Normal file
View File

@@ -0,0 +1,86 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from './configuration';
// Some imports not used depending on template conditions
// @ts-ignore
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
import globalAxios from 'axios';
export const BASE_PATH = "http://localhost:8090".replace(/\/+$/, "");
/**
*
* @export
*/
export const COLLECTION_FORMATS = {
csv: ",",
ssv: " ",
tsv: "\t",
pipes: "|",
};
/**
*
* @export
* @interface RequestArgs
*/
export interface RequestArgs {
url: string;
options: RawAxiosRequestConfig;
}
/**
*
* @export
* @class BaseAPI
*/
export class BaseAPI {
protected configuration: Configuration | undefined;
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
if (configuration) {
this.configuration = configuration;
this.basePath = configuration.basePath ?? basePath;
}
}
};
/**
*
* @export
* @class RequiredError
* @extends {Error}
*/
export class RequiredError extends Error {
constructor(public field: string, msg?: string) {
super(msg);
this.name = "RequiredError"
}
}
interface ServerMap {
[key: string]: {
url: string,
description: string,
}[];
}
/**
*
* @export
*/
export const operationServerMap: ServerMap = {
}

150
console/src/api/common.ts Normal file
View File

@@ -0,0 +1,150 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
import type { Configuration } from "./configuration";
import type { RequestArgs } from "./base";
import type { AxiosInstance, AxiosResponse } from 'axios';
import { RequiredError } from "./base";
/**
*
* @export
*/
export const DUMMY_BASE_URL = 'https://example.com'
/**
*
* @throws {RequiredError}
* @export
*/
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
if (paramValue === null || paramValue === undefined) {
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
}
}
/**
*
* @export
*/
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
if (configuration && configuration.apiKey) {
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
? await configuration.apiKey(keyParamName)
: await configuration.apiKey;
object[keyParamName] = localVarApiKeyValue;
}
}
/**
*
* @export
*/
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
if (configuration && (configuration.username || configuration.password)) {
object["auth"] = { username: configuration.username, password: configuration.password };
}
}
/**
*
* @export
*/
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const accessToken = typeof configuration.accessToken === 'function'
? await configuration.accessToken()
: await configuration.accessToken;
object["Authorization"] = "Bearer " + accessToken;
}
}
/**
*
* @export
*/
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
if (configuration && configuration.accessToken) {
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
? await configuration.accessToken(name, scopes)
: await configuration.accessToken;
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
}
}
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
if (parameter == null) return;
if (typeof parameter === "object") {
if (Array.isArray(parameter)) {
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
}
else {
Object.keys(parameter).forEach(currentKey =>
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
);
}
}
else {
if (urlSearchParams.has(key)) {
urlSearchParams.append(key, parameter);
}
else {
urlSearchParams.set(key, parameter);
}
}
}
/**
*
* @export
*/
export const setSearchParams = function (url: URL, ...objects: any[]) {
const searchParams = new URLSearchParams(url.search);
setFlattenedQueryParams(searchParams, objects);
url.search = searchParams.toString();
}
/**
*
* @export
*/
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
const nonString = typeof value !== 'string';
const needsSerialization = nonString && configuration && configuration.isJsonMime
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
: nonString;
return needsSerialization
? JSON.stringify(value !== undefined ? value : {})
: (value || "");
}
/**
*
* @export
*/
export const toPathString = function (url: URL) {
return url.pathname + url.search + url.hash
}
/**
*
* @export
*/
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
return axios.request<T, R>(axiosRequestArgs);
};
}

View File

@@ -0,0 +1,110 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
basePath?: string;
serverIndex?: number;
baseOptions?: any;
formDataCtor?: new () => any;
}
export class Configuration {
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
username?: string;
/**
* parameter for basic security
*
* @type {string}
* @memberof Configuration
*/
password?: string;
/**
* parameter for oauth2 security
* @param name security name
* @param scopes oauth2 scope
* @memberof Configuration
*/
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
/**
* override base path
*
* @type {string}
* @memberof Configuration
*/
basePath?: string;
/**
* override server index
*
* @type {number}
* @memberof Configuration
*/
serverIndex?: number;
/**
* base options for axios calls
*
* @type {any}
* @memberof Configuration
*/
baseOptions?: any;
/**
* The FormData constructor that will be used to create multipart form data
* requests. You can inject this here so that execution environments that
* do not support the FormData class can still run the generated client.
*
* @type {new () => FormData}
*/
formDataCtor?: new () => any;
constructor(param: ConfigurationParameters = {}) {
this.apiKey = param.apiKey;
this.username = param.username;
this.password = param.password;
this.accessToken = param.accessToken;
this.basePath = param.basePath;
this.serverIndex = param.serverIndex;
this.baseOptions = param.baseOptions;
this.formDataCtor = param.formDataCtor;
}
/**
* Check if the given MIME is a JSON MIME.
* JSON MIME examples:
* application/json
* application/json; charset=UTF8
* APPLICATION/JSON
* application/vnd.company+json
* @param mime - MIME (Multipurpose Internet Mail Extensions)
* @return True if the given MIME is JSON, false otherwise.
*/
public isJsonMime(mime: string): boolean {
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
}
}

18
console/src/api/index.ts Normal file
View File

@@ -0,0 +1,18 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
export * from "./api";
export * from "./configuration";
export * from "./models";

View File

@@ -0,0 +1,49 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface AddOperation
*/
export interface AddOperation {
/**
*
* @type {string}
* @memberof AddOperation
*/
'op': AddOperationOpEnum;
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof AddOperation
*/
'path': string;
/**
* Value can be any JSON value
* @type {any}
* @memberof AddOperation
*/
'value': any;
}
export const AddOperationOpEnum = {
Add: 'add'
} as const;
export type AddOperationOpEnum = typeof AddOperationOpEnum[keyof typeof AddOperationOpEnum];

View File

@@ -0,0 +1,66 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface AttachmentSpec
*/
export interface AttachmentSpec {
/**
* Display name of attachment
* @type {string}
* @memberof AttachmentSpec
*/
'displayName'?: string;
/**
* Group name
* @type {string}
* @memberof AttachmentSpec
*/
'groupName'?: string;
/**
* Media type of attachment
* @type {string}
* @memberof AttachmentSpec
*/
'mediaType'?: string;
/**
* Name of User who uploads the attachment
* @type {string}
* @memberof AttachmentSpec
*/
'ownerName'?: string;
/**
* Policy name
* @type {string}
* @memberof AttachmentSpec
*/
'policyName'?: string;
/**
* Size of attachment. Unit is Byte
* @type {number}
* @memberof AttachmentSpec
*/
'size'?: number;
/**
* Tags of attachment
* @type {Array<string>}
* @memberof AttachmentSpec
*/
'tags'?: Array<string>;
}

View File

@@ -0,0 +1,30 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface AttachmentStatus
*/
export interface AttachmentStatus {
/**
* Permalink of attachment. If it is in local storage, the public URL will be set. If it is in s3 storage, the Object URL will be set.
* @type {string}
* @memberof AttachmentStatus
*/
'permalink'?: string;
}

View File

@@ -0,0 +1,63 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import type { AttachmentSpec } from './attachment-spec';
// May contain unused imports in some cases
// @ts-ignore
import type { AttachmentStatus } from './attachment-status';
// May contain unused imports in some cases
// @ts-ignore
import type { Metadata } from './metadata';
/**
*
* @export
* @interface Attachment
*/
export interface Attachment {
/**
*
* @type {string}
* @memberof Attachment
*/
'apiVersion': string;
/**
*
* @type {string}
* @memberof Attachment
*/
'kind': string;
/**
*
* @type {Metadata}
* @memberof Attachment
*/
'metadata': Metadata;
/**
*
* @type {AttachmentSpec}
* @memberof Attachment
*/
'spec': AttachmentSpec;
/**
*
* @type {AttachmentStatus}
* @memberof Attachment
*/
'status'?: AttachmentStatus;
}

View File

@@ -0,0 +1,49 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface CopyOperation
*/
export interface CopyOperation {
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof CopyOperation
*/
'from': string;
/**
*
* @type {string}
* @memberof CopyOperation
*/
'op': CopyOperationOpEnum;
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof CopyOperation
*/
'path': string;
}
export const CopyOperationOpEnum = {
Copy: 'copy'
} as const;
export type CopyOperationOpEnum = typeof CopyOperationOpEnum[keyof typeof CopyOperationOpEnum];

View File

@@ -0,0 +1,20 @@
export * from './add-operation';
export * from './attachment';
export * from './attachment-spec';
export * from './attachment-status';
export * from './copy-operation';
export * from './json-patch-inner';
export * from './link-request';
export * from './link-result';
export * from './link-result-item';
export * from './metadata';
export * from './move-operation';
export * from './object-vo';
export * from './policy';
export * from './policy-spec';
export * from './remove-operation';
export * from './replace-operation';
export * from './s3-list-result';
export * from './s3-os-properties';
export * from './test-operation';
export * from './url-suffix-item';

View File

@@ -0,0 +1,41 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import type { AddOperation } from './add-operation';
// May contain unused imports in some cases
// @ts-ignore
import type { CopyOperation } from './copy-operation';
// May contain unused imports in some cases
// @ts-ignore
import type { MoveOperation } from './move-operation';
// May contain unused imports in some cases
// @ts-ignore
import type { RemoveOperation } from './remove-operation';
// May contain unused imports in some cases
// @ts-ignore
import type { ReplaceOperation } from './replace-operation';
// May contain unused imports in some cases
// @ts-ignore
import type { TestOperation } from './test-operation';
/**
* @type JsonPatchInner
* @export
*/
export type JsonPatchInner = AddOperation | CopyOperation | MoveOperation | RemoveOperation | ReplaceOperation | TestOperation;

View File

@@ -0,0 +1,42 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface LinkRequest
*/
export interface LinkRequest {
/**
*
* @type {string}
* @memberof LinkRequest
*/
'groupName'?: string;
/**
*
* @type {Array<string>}
* @memberof LinkRequest
*/
'objectKeys'?: Array<string>;
/**
*
* @type {string}
* @memberof LinkRequest
*/
'policyName'?: string;
}

View File

@@ -0,0 +1,42 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface LinkResultItem
*/
export interface LinkResultItem {
/**
*
* @type {string}
* @memberof LinkResultItem
*/
'message'?: string;
/**
*
* @type {string}
* @memberof LinkResultItem
*/
'objectKey'?: string;
/**
*
* @type {boolean}
* @memberof LinkResultItem
*/
'success'?: boolean;
}

View File

@@ -0,0 +1,33 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import type { LinkResultItem } from './link-result-item';
/**
*
* @export
* @interface LinkResult
*/
export interface LinkResult {
/**
*
* @type {Array<LinkResultItem>}
* @memberof LinkResult
*/
'items'?: Array<LinkResultItem>;
}

View File

@@ -0,0 +1,72 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface Metadata
*/
export interface Metadata {
/**
*
* @type {{ [key: string]: string; }}
* @memberof Metadata
*/
'annotations'?: { [key: string]: string; };
/**
*
* @type {string}
* @memberof Metadata
*/
'creationTimestamp'?: string | null;
/**
*
* @type {string}
* @memberof Metadata
*/
'deletionTimestamp'?: string | null;
/**
*
* @type {Array<string>}
* @memberof Metadata
*/
'finalizers'?: Array<string> | null;
/**
* The name field will be generated automatically according to the given generateName field
* @type {string}
* @memberof Metadata
*/
'generateName'?: string;
/**
*
* @type {{ [key: string]: string; }}
* @memberof Metadata
*/
'labels'?: { [key: string]: string; };
/**
* Metadata name
* @type {string}
* @memberof Metadata
*/
'name': string;
/**
*
* @type {number}
* @memberof Metadata
*/
'version'?: number | null;
}

View File

@@ -0,0 +1,49 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface MoveOperation
*/
export interface MoveOperation {
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof MoveOperation
*/
'from': string;
/**
*
* @type {string}
* @memberof MoveOperation
*/
'op': MoveOperationOpEnum;
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof MoveOperation
*/
'path': string;
}
export const MoveOperationOpEnum = {
Move: 'move'
} as const;
export type MoveOperationOpEnum = typeof MoveOperationOpEnum[keyof typeof MoveOperationOpEnum];

View File

@@ -0,0 +1,48 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface ObjectVo
*/
export interface ObjectVo {
/**
*
* @type {string}
* @memberof ObjectVo
*/
'displayName'?: string;
/**
*
* @type {boolean}
* @memberof ObjectVo
*/
'isLinked'?: boolean;
/**
*
* @type {string}
* @memberof ObjectVo
*/
'key'?: string;
/**
*
* @type {string}
* @memberof ObjectVo
*/
'lastModified'?: string;
}

View File

@@ -0,0 +1,42 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface PolicySpec
*/
export interface PolicySpec {
/**
* Reference name of ConfigMap extension
* @type {string}
* @memberof PolicySpec
*/
'configMapName'?: string;
/**
* Display name of policy
* @type {string}
* @memberof PolicySpec
*/
'displayName': string;
/**
* Reference name of PolicyTemplate
* @type {string}
* @memberof PolicySpec
*/
'templateName': string;
}

View File

@@ -0,0 +1,54 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import type { Metadata } from './metadata';
// May contain unused imports in some cases
// @ts-ignore
import type { PolicySpec } from './policy-spec';
/**
*
* @export
* @interface Policy
*/
export interface Policy {
/**
*
* @type {string}
* @memberof Policy
*/
'apiVersion': string;
/**
*
* @type {string}
* @memberof Policy
*/
'kind': string;
/**
*
* @type {Metadata}
* @memberof Policy
*/
'metadata': Metadata;
/**
*
* @type {PolicySpec}
* @memberof Policy
*/
'spec': PolicySpec;
}

View File

@@ -0,0 +1,43 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface RemoveOperation
*/
export interface RemoveOperation {
/**
*
* @type {string}
* @memberof RemoveOperation
*/
'op': RemoveOperationOpEnum;
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof RemoveOperation
*/
'path': string;
}
export const RemoveOperationOpEnum = {
Remove: 'remove'
} as const;
export type RemoveOperationOpEnum = typeof RemoveOperationOpEnum[keyof typeof RemoveOperationOpEnum];

View File

@@ -0,0 +1,49 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface ReplaceOperation
*/
export interface ReplaceOperation {
/**
*
* @type {string}
* @memberof ReplaceOperation
*/
'op': ReplaceOperationOpEnum;
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof ReplaceOperation
*/
'path': string;
/**
* Value can be any JSON value
* @type {any}
* @memberof ReplaceOperation
*/
'value': any;
}
export const ReplaceOperationOpEnum = {
Replace: 'replace'
} as const;
export type ReplaceOperationOpEnum = typeof ReplaceOperationOpEnum[keyof typeof ReplaceOperationOpEnum];

View File

@@ -0,0 +1,63 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import type { ObjectVo } from './object-vo';
/**
*
* @export
* @interface S3ListResult
*/
export interface S3ListResult {
/**
*
* @type {string}
* @memberof S3ListResult
*/
'currentContinuationObject'?: string;
/**
*
* @type {string}
* @memberof S3ListResult
*/
'currentToken'?: string;
/**
*
* @type {boolean}
* @memberof S3ListResult
*/
'hasMore'?: boolean;
/**
*
* @type {string}
* @memberof S3ListResult
*/
'nextContinuationObject'?: string;
/**
*
* @type {string}
* @memberof S3ListResult
*/
'nextToken'?: string;
/**
*
* @type {Array<ObjectVo>}
* @memberof S3ListResult
*/
'objects'?: Array<ObjectVo>;
}

View File

@@ -0,0 +1,151 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
// May contain unused imports in some cases
// @ts-ignore
import type { UrlSuffixItem } from './url-suffix-item';
/**
*
* @export
* @interface S3OsProperties
*/
export interface S3OsProperties {
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'accessKey'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'accessSecret'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'bucket'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'customTemplate'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'domain'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'duplicateFilenameHandling'?: S3OsPropertiesDuplicateFilenameHandlingEnum;
/**
*
* @type {boolean}
* @memberof S3OsProperties
*/
'enablePathStyleAccess'?: boolean;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'endpoint'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'endpointProtocol'?: S3OsPropertiesEndpointProtocolEnum;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'location'?: string;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'protocol'?: S3OsPropertiesProtocolEnum;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'randomFilenameMode'?: S3OsPropertiesRandomFilenameModeEnum;
/**
*
* @type {number}
* @memberof S3OsProperties
*/
'randomStringLength'?: number;
/**
*
* @type {string}
* @memberof S3OsProperties
*/
'region'?: string;
/**
*
* @type {Array<UrlSuffixItem>}
* @memberof S3OsProperties
*/
'urlSuffixes'?: Array<UrlSuffixItem>;
}
export const S3OsPropertiesDuplicateFilenameHandlingEnum = {
RandomAlphanumeric: 'randomAlphanumeric',
RandomAlphabetic: 'randomAlphabetic',
Exception: 'exception'
} as const;
export type S3OsPropertiesDuplicateFilenameHandlingEnum = typeof S3OsPropertiesDuplicateFilenameHandlingEnum[keyof typeof S3OsPropertiesDuplicateFilenameHandlingEnum];
export const S3OsPropertiesEndpointProtocolEnum = {
Http: 'http',
Https: 'https'
} as const;
export type S3OsPropertiesEndpointProtocolEnum = typeof S3OsPropertiesEndpointProtocolEnum[keyof typeof S3OsPropertiesEndpointProtocolEnum];
export const S3OsPropertiesProtocolEnum = {
Http: 'http',
Https: 'https'
} as const;
export type S3OsPropertiesProtocolEnum = typeof S3OsPropertiesProtocolEnum[keyof typeof S3OsPropertiesProtocolEnum];
export const S3OsPropertiesRandomFilenameModeEnum = {
None: 'none',
Custom: 'custom',
Uuid: 'uuid',
TimestampMs: 'timestampMs',
DateWithString: 'dateWithString',
DatetimeWithString: 'datetimeWithString',
WithString: 'withString',
String: 'string',
RandomNumber: 'random_number'
} as const;
export type S3OsPropertiesRandomFilenameModeEnum = typeof S3OsPropertiesRandomFilenameModeEnum[keyof typeof S3OsPropertiesRandomFilenameModeEnum];

View File

@@ -0,0 +1,49 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface TestOperation
*/
export interface TestOperation {
/**
*
* @type {string}
* @memberof TestOperation
*/
'op': TestOperationOpEnum;
/**
* A JSON Pointer path pointing to the location to move/copy from.
* @type {string}
* @memberof TestOperation
*/
'path': string;
/**
* Value can be any JSON value
* @type {any}
* @memberof TestOperation
*/
'value': any;
}
export const TestOperationOpEnum = {
Test: 'test'
} as const;
export type TestOperationOpEnum = typeof TestOperationOpEnum[keyof typeof TestOperationOpEnum];

View File

@@ -0,0 +1,36 @@
/* tslint:disable */
/* eslint-disable */
/**
* Halo
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 2.18.0-SNAPSHOT
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface UrlSuffixItem
*/
export interface UrlSuffixItem {
/**
*
* @type {string}
* @memberof UrlSuffixItem
*/
'fileSuffix'?: string;
/**
*
* @type {string}
* @memberof UrlSuffixItem
*/
'urlSuffix'?: string;
}

View File

@@ -1,2 +0,0 @@
export * from "./s-3-link-controller";
export * from "./s-3-unlink-controller";

View File

@@ -1,25 +0,0 @@
import request from "@/utils/request";
import { S3ListResult, DeepRequired } from "../../interface";
/**
* /apis/s3os.halo.run/v1alpha1/objects/{policyName}
*/
export function getApisS3OsHaloRunV1Alpha1ObjectsByPolicyName(params: GetApisS3OsHaloRunV1Alpha1ObjectsByPolicyNameParams) {
const paramsInput = {
continuationToken: params.continuationToken,
continuationObject: params.continuationObject,
pageSize: params.pageSize,
unlinked: params.unlinked,
};
return request.get<DeepRequired<S3ListResult>>(`/apis/s3os.halo.run/v1alpha1/objects/${params.policyName}`, {
params: paramsInput,
});
}
interface GetApisS3OsHaloRunV1Alpha1ObjectsByPolicyNameParams {
policyName: any;
continuationToken?: any;
continuationObject?: any;
pageSize: any;
unlinked?: any;
}

View File

@@ -1,9 +0,0 @@
import request from "@/utils/request";
import { DeepRequired } from "../../interface";
/**
* /apis/s3os.halo.run/v1alpha1/policies/s3
*/
export function getApisS3OsHaloRunV1Alpha1PoliciesS3() {
return request.get<DeepRequired<any>>(`/apis/s3os.halo.run/v1alpha1/policies/s3`);
}

View File

@@ -1,3 +0,0 @@
export * from "./postApisS3OsHaloRunV1Alpha1AttachmentsLink";
export * from "./getApisS3OsHaloRunV1Alpha1ObjectsByPolicyName";
export * from "./getApisS3OsHaloRunV1Alpha1PoliciesS3";

View File

@@ -1,9 +0,0 @@
import request from "@/utils/request";
import { LinkResult, DeepRequired, LinkRequest } from "../../interface";
/**
* /apis/s3os.halo.run/v1alpha1/attachments/link
*/
export function postApisS3OsHaloRunV1Alpha1AttachmentsLink(input: LinkRequest) {
return request.post<DeepRequired<LinkResult>>(`/apis/s3os.halo.run/v1alpha1/attachments/link`, input);
}

View File

@@ -1,14 +0,0 @@
import request from "@/utils/request";
import { DeepRequired } from "../../interface";
import { Attachment } from "@halo-dev/api-client";
/**
* /apis/s3os.halo.run/v1alpha1/attachments/{name}
*/
export function deleteApisS3OsHaloRunV1Alpha1AttachmentsByName(params: DeleteApisS3OsHaloRunV1Alpha1AttachmentsByNameParams) {
return request.delete<DeepRequired<Attachment>>(`/apis/s3os.halo.run/v1alpha1/attachments/${params.name}`);
}
interface DeleteApisS3OsHaloRunV1Alpha1AttachmentsByNameParams {
name: any;
}

View File

@@ -1 +0,0 @@
export * from "./deleteApisS3OsHaloRunV1Alpha1AttachmentsByName";

View File

@@ -1,10 +1,10 @@
import type { Ref } from "vue";
import { markRaw } from "vue";
import CarbonFolderDetailsReference from "~icons/carbon/folder-details-reference";
import type { Attachment } from "@halo-dev/api-client";
import { definePlugin } from "@halo-dev/console-shared";
import S3Link from "./views/S3Link.vue";
import S3Unlink from "./views/S3Unlink.vue";
import type { Ref } from "vue";
import { markRaw } from "vue";
import CarbonFolderDetailsReference from "~icons/carbon/folder-details-reference";
export default definePlugin({
components: {},

View File

@@ -1,4 +0,0 @@
export interface LinkRequest {
objectKeys?: string[];
policyName?: string;
}

View File

@@ -1,5 +0,0 @@
import { LinkResultItem } from "../../interface";
export interface LinkResult {
items?: LinkResultItem[];
}

View File

@@ -1,5 +0,0 @@
export interface LinkResultItem {
message?: string;
objectKey?: string;
success?: boolean;
}

View File

@@ -1,20 +0,0 @@
export interface Metadata {
annotations?: MetadataAnnotations;
creationTimestamp?: string;
deletionTimestamp?: string;
finalizers?: string[];
/** The name field will be generated automatically according to the given generateName field */
generateName?: string;
labels?: MetadataLabels;
/** Metadata name */
name: string;
version?: number;
}
export interface MetadataAnnotations {
[key: string]: any;
}
export interface MetadataLabels {
[key: string]: any;
}

View File

@@ -1,6 +0,0 @@
export interface ObjectVo {
displayName?: string;
isLinked?: boolean;
key?: string;
lastModified?: string;
}

View File

@@ -1,8 +0,0 @@
import { Metadata, PolicySpec } from "../../interface";
export interface Policy {
apiVersion: string;
kind: string;
metadata: Metadata;
spec: PolicySpec;
}

View File

@@ -1,8 +0,0 @@
export interface PolicySpec {
/** Reference name of ConfigMap extension */
configMapName?: string;
/** Display name of policy */
displayName: string;
/** Reference name of PolicyTemplate */
templateName: string;
}

View File

@@ -1,10 +0,0 @@
import { ObjectVo } from "../../interface";
export interface S3ListResult {
currentContinuationObject?: string;
currentToken?: string;
hasMore?: boolean;
nextContinuationObject?: string;
nextToken?: string;
objects?: ObjectVo[];
}

View File

@@ -1,11 +0,0 @@
export * from "./apiTypes/LinkRequest";
export * from "./apiTypes/LinkResult";
export * from "./apiTypes/LinkResultItem";
export * from "./apiTypes/Metadata";
export * from "./apiTypes/ObjectVo";
export * from "./apiTypes/Policy";
export * from "./apiTypes/PolicySpec";
export * from "./apiTypes/S3ListResult";
export type Primitive = undefined | null | boolean | string | number | symbol;
export type DeepRequired<T> = T extends Primitive ? T : keyof T extends never ? T : { [K in keyof T]-?: DeepRequired<T[K]> };

View File

@@ -1,7 +0,0 @@
{
"docsUrl": "http://localhost:8090/v3/api-docs/extension-api",
"includeTags": ["s-3-link-controller", "s-3-unlink-controller"],
"excludeTags": [],
"axiosInstanceUrl": "@/utils/request",
"prefix": ""
}

View File

@@ -1,31 +0,0 @@
import axios from "axios";
import {Toast} from "@halo-dev/components";
const baseURL = import.meta.env.VITE_API_URL;
const request = axios.create({
baseURL,
withCredentials: true,
});
// 非200状态码就弹窗
request.interceptors.response.use(
(response) => {
return response;
},
async (error) => {
const errorResponse = error.response;
if (!errorResponse) {
return Promise.reject(error);
}
const { status } = errorResponse;
if (status !== 200) {
Toast.error("status: " + status);
}
return Promise.reject(error);
}
);
request.defaults.headers.common["X-Requested-With"] = "XMLHttpRequest";
// TODO 使用halo console 中的axios https://github.com/halo-dev/halo/issues/3979
export default request;

View File

@@ -1,5 +1,7 @@
<script setup lang="ts">
import { computed, getCurrentInstance, onMounted, ref, watch } from "vue";
import {
IconCheckboxCircle,
IconRefreshLine,
Toast,
VButton,
@@ -11,26 +13,51 @@ import {
VModal,
VPageHeader,
VSpace,
VStatusDot,
VTag,
} from "@halo-dev/components";
import CarbonFolderDetailsReference from "~icons/carbon/folder-details-reference";
import {computed, onMounted, ref, watch} from "vue";
import {
getApisS3OsHaloRunV1Alpha1ObjectsByPolicyName,
getApisS3OsHaloRunV1Alpha1PoliciesS3,
postApisS3OsHaloRunV1Alpha1AttachmentsLink,
} from "@/controller";
import type {ObjectVo, S3ListResult, Policy, LinkResultItem} from "@/interface";
import IconErrorWarning from "~icons/ri/error-warning-line";
import { axiosInstance, coreApiClient, type Group } from "@halo-dev/api-client";
import { S3LinkControllerApi } from "@/api";
import type { S3ListResult, LinkResultItem, Policy, ObjectVo } from "@/api";
const s3LinkControllerApi = new S3LinkControllerApi(undefined, axiosInstance.defaults.baseURL, axiosInstance);
const componentInstance = getCurrentInstance();
const t = (key: string) => {
// @ts-ignore
if (typeof componentInstance?.proxy?.$t === 'function') {
// @ts-ignore
return componentInstance.proxy.$t(key);
}
return key;
};
const selectedFiles = ref<string[]>([]);
const policyName = ref<string>("");
const page = ref(1);
const size = ref(50);
const selectedGroup = ref("")
const policyOptions = ref<{ label: string; value: string; attrs: any }[]>([{
label: "请选择策略",
label: "请选择存储策略",
value: "",
attrs: {disabled: true}
}]);
const defaultGroup = ref<Group>({
apiVersion: "",
kind: "",
metadata: {
name: "",
},
spec: {
displayName: t("core.attachment.common.text.ungrouped"),
},
});
// update when fetch first page
const filePrefix = ref<string>("");
// update when user input
const filePrefixBind = ref<string>("");
const s3Objects = ref<S3ListResult>({
objects: [],
hasMore: false,
@@ -39,6 +66,7 @@ const s3Objects = ref<S3ListResult>({
currentContinuationObject: "",
nextContinuationObject: "",
});
const customGroups = ref<Group[]>([]);
// view state
const isFetching = ref(false);
const isShowModal = ref(false);
@@ -58,18 +86,15 @@ const selectedLinkedStatusItem = ref<boolean | undefined>(linkedStatusItems[0].v
const emptyTips = computed(() => {
if (isFetchingPolicies.value) {
return "正在加载策略";
} else {
if (policyOptions.value.length <= 1) {
return "没有可用的策略请前往【附件】添加S3策略";
} else {
if (!policyName.value) {
return "请在左上方选择策略";
} else {
return "该策略的 桶/文件夹 下没有文件";
}
}
return "正在加载存储策略";
}
if (policyOptions.value.length <= 1) {
return "没有可用的存储策略请前往【附件】添加S3存储策略";
}
if (!policyName.value) {
return "请在左上方选择存储策略";
}
return "该存储策略的 桶/文件夹 下没有文件";
});
const handleCheckAllChange = (e: Event) => {
@@ -89,14 +114,14 @@ const handleCheckAllChange = (e: Event) => {
const fetchPolicies = async () => {
try {
const policiesData = await getApisS3OsHaloRunV1Alpha1PoliciesS3();
if (policiesData.status == 200) {
const {status, data} = await s3LinkControllerApi.listS3Policies();
if (status === 200) {
policyOptions.value = [{
label: "请选择策略",
label: "请选择存储策略",
value: "",
attrs: {disabled: true}
}];
policiesData.data.forEach((policy: Policy) => {
data.forEach((policy: Policy) => {
policyOptions.value.push({
label: policy.spec.displayName,
value: policy.metadata.name,
@@ -110,21 +135,6 @@ const fetchPolicies = async () => {
isFetchingPolicies.value = false;
};
onMounted(() => {
fetchPolicies();
});
watch(selectedFiles, (newValue) => {
checkedAll.value = s3Objects.value.objects?.filter(file => !file.isLinked)
.filter(file => !newValue.includes(file.key || "")).length == 0
&& s3Objects.value.objects?.length != 0;
});
watch(selectedLinkedStatusItem, () => {
handleFirstPage();
});
const changeNextTokenAndObject = () => {
s3Objects.value.currentToken = s3Objects.value.nextToken;
s3Objects.value.currentContinuationObject = s3Objects.value.nextContinuationObject;
@@ -139,6 +149,8 @@ const clearTokenAndObject = () => {
s3Objects.value.nextContinuationObject = "";
};
// filePrefix will not be updated from user input
// if you want to update filePrefix, please call `handleFirstPage`
const fetchObjects = async () => {
if (!policyName.value) {
return;
@@ -146,20 +158,20 @@ const fetchObjects = async () => {
isFetching.value = true;
s3Objects.value.objects = [];
try {
const objectsData = await getApisS3OsHaloRunV1Alpha1ObjectsByPolicyName({
const {status, data} = await s3LinkControllerApi.listObjects({
policyName: policyName.value,
pageSize: size.value,
continuationToken: s3Objects.value.currentToken,
continuationObject: s3Objects.value.currentContinuationObject,
unlinked: selectedLinkedStatusItem.value,
filePrefix: filePrefix.value
});
if (objectsData.status == 200) {
s3Objects.value = objectsData.data;
if (s3Objects.value.objects?.length == 0 && s3Objects.value.hasMore && s3Objects.value.nextToken) {
if (status === 200) {
s3Objects.value = data;
if (s3Objects.value.objects?.length === 0 && s3Objects.value.hasMore && s3Objects.value.nextToken) {
changeNextTokenAndObject();
await fetchObjects();
} else if (s3Objects.value.objects?.length == 0 && !s3Objects.value.hasMore && page.value > 1) {
} else if (s3Objects.value.objects?.length === 0 && !s3Objects.value.hasMore && page.value > 1) {
page.value = 1;
clearTokenAndObject();
await fetchObjects();
@@ -183,17 +195,20 @@ const handleLink = async () => {
isShowModal.value = true;
linkTips.value = `正在关联${selectedFiles.value.length}个文件`;
linkFailedTable.value = [];
const linkResult = await postApisS3OsHaloRunV1Alpha1AttachmentsLink({
policyName: policyName.value,
objectKeys: selectedFiles.value
const linkResult = await s3LinkControllerApi.addAttachmentRecord({
linkRequest: {
policyName: policyName.value,
objectKeys: selectedFiles.value,
groupName: selectedGroup.value,
}
});
const successCount = linkResult.data.items.filter(item => item.success).length;
const failedCount = linkResult.data.items.filter(item => !item.success).length;
const items = linkResult.data.items || [];
const successCount = items.filter(item => item.success).length;
const failedCount = items.filter(item => !item.success).length;
linkTips.value = `关联成功${successCount}个文件,关联失败${failedCount}个文件`;
if (failedCount > 0) {
linkFailedTable.value = linkResult.data.items.filter(item => !item.success);
linkFailedTable.value = items.filter(item => !item.success);
}
isLinking.value = false;
};
@@ -204,15 +219,13 @@ const selectOneAndLink = (file: ObjectVo) => {
};
const handleNextPage = () => {
if (!policyName.value) {
if (!policyName.value || !s3Objects.value.hasMore) {
return;
}
if (s3Objects.value.hasMore) {
isFetching.value = true;
page.value += 1;
changeNextTokenAndObject();
fetchObjects();
}
isFetching.value = true;
page.value += 1;
changeNextTokenAndObject();
fetchObjects();
};
const handleFirstPage = () => {
@@ -222,6 +235,7 @@ const handleFirstPage = () => {
isFetching.value = true;
page.value = 1;
clearTokenAndObject();
filePrefix.value = filePrefixBind.value;
fetchObjects();
};
@@ -229,10 +243,34 @@ const handleModalClose = () => {
isShowModal.value = false;
fetchObjects();
};
const fetchCustomGroups = async () => {
const {status, data} = await coreApiClient.storage.group.listGroup({
labelSelector: ["!halo.run/hidden"],
sort: ["metadata.creationTimestamp,asc"],
});
if (status === 200) {
customGroups.value = data.items;
}
};
onMounted(() => {
fetchPolicies();
fetchCustomGroups();
});
watch(selectedFiles, (newValue) => {
checkedAll.value = s3Objects.value.objects?.filter(file => !file.isLinked)
.filter(file => !newValue.includes(file.key || "")).length === 0
&& s3Objects.value.objects?.length !== 0;
});
watch(selectedLinkedStatusItem, handleFirstPage);
</script>
<template>
<VPageHeader title="关联S3文件(Beta)">
<VPageHeader title="关联S3文件">
<template #icon>
<CarbonFolderDetailsReference class="mr-2 self-center"/>
</template>
@@ -255,18 +293,26 @@ const handleModalClose = () => {
<div class="flex w-full flex-1 items-center sm:w-auto">
<div
v-if="!selectedFiles.length"
class="flex items-center gap-2"
class="flex flex-wrap items-center gap-2"
>
策略:
<span class="whitespace-nowrap">存储策略:</span>
<FormKit
id="policyChoose"
outer-class="!p-0 w-48"
outer-class="!p-0"
style="min-width: 10rem;"
v-model="policyName"
name="policyName"
type="select"
:options="policyOptions"
@change="fetchObjects()"
@change="handleFirstPage"
></FormKit>
<icon-error-warning v-if="!policyName" class="text-red-500"/>
<SearchInput
v-model="filePrefixBind"
v-if="policyName"
placeholder="请输入文件名前缀搜索"
@update:modelValue="handleFirstPage"
></SearchInput>
</div>
<VSpace v-else>
<VButton type="primary" @click="handleLink">
@@ -319,6 +365,37 @@ const handleModalClose = () => {
class="box-border h-full w-full divide-y divide-gray-100"
role="list"
>
<li style="padding: 0.5rem 1rem 0">
<span class="ml-1 mb-1 block text-sm text-gray-500">关联后所加入的分组</span>
<div class="mb-5 grid grid-cols-2 gap-x-2 gap-y-3 md:grid-cols-3 lg:grid-cols-4 2xl:grid-cols-6">
<button
type="button"
class="inline-flex h-full w-full items-center gap-2 rounded-md border border-gray-200 bg-white px-3 py-2.5 text-sm font-medium text-gray-800 hover:bg-gray-50 hover:shadow-sm"
v-for="(group, index) in [defaultGroup, ...customGroups]"
:key="index"
:class="{ '!bg-gray-100 shadow-sm': group.metadata.name === selectedGroup }"
@click="selectedGroup = group.metadata.name"
>
<div class="inline-flex w-full flex-1 gap-x-2 break-all text-left">
<slot name="text">
{{ group?.spec.displayName }}
</slot>
<VStatusDot
v-if="group?.metadata.deletionTimestamp"
v-tooltip="$t('core.common.status.deleting')"
state="warning"
animate
/>
</div>
<div class="flex-none">
<IconCheckboxCircle
v-if="group.metadata.name === selectedGroup"
class="text-primary"
/>
</div>
</button>
</div>
</li>
<li v-for="(file, index) in s3Objects.objects" :key="index">
<VEntity :is-selected="checkSelection(file)">
<template
@@ -383,11 +460,11 @@ const handleModalClose = () => {
</div>
<div class="inline-flex items-center gap-5">
<div class="inline-flex items-center gap-2">
<VButton size="small" @click="handleFirstPage" :disabled="!policyName">返回第一页</VButton>
<VButton @click="handleFirstPage" :disabled="!policyName">返回第一页</VButton>
<span class="text-sm text-gray-500"> {{ page }} </span>
<VButton size="small" @click="handleNextPage" :disabled="!s3Objects.hasMore || isFetching || !policyName">
<VButton @click="handleNextPage" :disabled="!s3Objects.hasMore || isFetching || !policyName">
下一页
</VButton>
</div>
@@ -439,8 +516,8 @@ const handleModalClose = () => {
<th class="border border-black font-normal">失败原因</th>
</tr>
<tr v-for="failedInfo in linkFailedTable" :key="failedInfo.objectKey">
<th class="border border-black font-normal">{{failedInfo.objectKey}}</th>
<th class="border border-black font-normal">{{failedInfo.message}}</th>
<th class="border border-black font-normal">{{ failedInfo.objectKey }}</th>
<th class="border border-black font-normal">{{ failedInfo.message }}</th>
</tr>
</table>
</div>
@@ -450,6 +527,6 @@ const handleModalClose = () => {
<style lang="scss" scoped>
.page-size-select:focus {
--tw-border-opacity: 1;
border-color: rgba(var(--colors-primary),var(--tw-border-opacity));
border-color: rgba(var(--colors-primary), var(--tw-border-opacity));
}
</style>

View File

@@ -1,8 +1,11 @@
<script setup lang="ts">
import {deleteApisS3OsHaloRunV1Alpha1AttachmentsByName} from "@/controller";
import type {Attachment} from "@halo-dev/api-client";
import {Dialog, Toast, VDropdownDivider, VDropdownItem} from "@halo-dev/components";
import {useQueryClient} from "@tanstack/vue-query";
import {axiosInstance} from "@halo-dev/api-client"
import type {Attachment} from "@halo-dev/api-client";
import {S3UnlinkControllerApi} from "@/api"
const s3UnlinkControllerApi = new S3UnlinkControllerApi(undefined, axiosInstance.defaults.baseURL, axiosInstance);
const props = defineProps<{
attachment: Attachment;
@@ -18,12 +21,12 @@ const handleUnlink = () => {
cancelText: "取消",
onConfirm: async () => {
try {
await deleteApisS3OsHaloRunV1Alpha1AttachmentsByName({name: props.attachment.metadata.name});
await s3UnlinkControllerApi.unlink({name: props.attachment.metadata.name});
Toast.success("解除关联成功");
} catch (e) {
console.error("Failed to delete attachment", e);
} finally {
queryClient.invalidateQueries({queryKey: ["attachments"]});
await queryClient.invalidateQueries({queryKey: ["attachments"]});
}
},
});

View File

@@ -1,5 +1,5 @@
{
"extends": "@vue/tsconfig/tsconfig.web.json",
"extends": "@vue/tsconfig/tsconfig.dom.json",
"include": ["./env.d.ts", "./src/**/*", "./src/**/*.vue"],
"exclude": ["./src/**/__tests__/*"],
"compilerOptions": {

View File

@@ -1,5 +1,5 @@
{
"extends": "@vue/tsconfig/tsconfig.node.json",
"extends": ["@tsconfig/node18/tsconfig.json", "@vue/tsconfig/tsconfig.json"],
"include": ["vite.config.*", "vitest.config.*", "cypress.config.*"],
"compilerOptions": {
"composite": true,

View File

@@ -1 +1 @@
version=1.8.0-SNAPSHOT
version=1.11.0-SNAPSHOT

View File

@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
zipStorePath=wrapper/dists

View File

@@ -1,6 +1,7 @@
pluginManagement {
repositories {
maven { url 'https://s01.oss.sonatype.org/content/repositories/snapshots' }
mavenCentral()
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
maven { url 'https://maven.aliyun.com/repository/spring-plugin' }
maven { url 'https://repo.spring.io/milestone' }

View File

@@ -6,6 +6,6 @@ import lombok.experimental.UtilityClass;
public class FilePathUtils {
public static String getFilePathByPlaceholder(String filePath) {
return PlaceholderReplacer.replacePlaceholders(filePath, "");
return PlaceholderReplacer.replacePlaceholders(filePath, null);
}
}

View File

@@ -1,13 +1,13 @@
package run.halo.s3os;
import java.util.Set;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import java.util.List;
@Data
@RequiredArgsConstructor
public class LinkRequest {
private String policyName;
private List<String> objectKeys;
private Set<String> objectKeys;
private String groupName;
}

View File

@@ -0,0 +1,123 @@
package run.halo.s3os;
import static run.halo.s3os.S3OsAttachmentHandler.MULTIPART_MIN_PART_SIZE;
import static run.halo.s3os.S3OsAttachmentHandler.checkResult;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.core.io.buffer.DataBufferUtils;
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.halo.app.infra.utils.PathUtils;
import run.halo.app.plugin.ApiVersion;
import software.amazon.awssdk.services.s3.model.CompleteMultipartUploadRequest;
import software.amazon.awssdk.services.s3.model.CompletedMultipartUpload;
import software.amazon.awssdk.services.s3.model.CreateMultipartUploadRequest;
import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
import software.amazon.awssdk.utils.SdkAutoCloseable;
@ApiVersion("s3os.halo.run/v1alpha1")
@RestController
@RequiredArgsConstructor
@Slf4j
public class PolicyConfigValidationController {
private final S3OsAttachmentHandler handler;
@PostMapping("/policies/s3/validation")
public Mono<Void> validatePolicyConfig(@RequestBody S3OsProperties properties) {
var filename = "halo-s3-plugin-test-file-" + System.currentTimeMillis() + ".jpg";
var content = readImage();
return Mono.using(() -> handler.buildS3Client(properties),
client -> {
var uploadState =
new S3OsAttachmentHandler.UploadState(properties, filename, false);
return handler.checkFileExistsAndRename(uploadState, client)
// init multipart upload
.flatMap(state -> Mono.fromCallable(() -> client.createMultipartUpload(
CreateMultipartUploadRequest.builder()
.bucket(properties.getBucket())
.contentType(state.contentType)
.key(state.objectKey)
.build())))
.doOnNext((response) -> {
checkResult(response, "createMultipartUpload");
uploadState.uploadId = response.uploadId();
})
.thenMany(handler.reshape(content, MULTIPART_MIN_PART_SIZE))
// buffer to part
.windowUntil((buffer) -> {
uploadState.buffered += buffer.readableByteCount();
if (uploadState.buffered >= MULTIPART_MIN_PART_SIZE) {
uploadState.buffered = 0;
return true;
} else {
return false;
}
})
// upload part
.concatMap((window) -> window.collectList().flatMap((bufferList) -> {
var buffer = S3OsAttachmentHandler.concatBuffers(bufferList);
return handler.uploadPart(uploadState, buffer, client);
}))
.reduce(uploadState, (state, completedPart) -> {
state.completedParts.put(completedPart.partNumber(), completedPart);
return state;
})
// complete multipart upload
.flatMap((state) -> Mono.just(client.completeMultipartUpload(
CompleteMultipartUploadRequest
.builder()
.bucket(properties.getBucket())
.uploadId(state.uploadId)
.multipartUpload(CompletedMultipartUpload.builder()
.parts(state.completedParts.values())
.build())
.key(state.objectKey)
.build())
))
// get object metadata
.flatMap((response) -> {
checkResult(response, "completeUpload");
return Mono.just(client.headObject(
HeadObjectRequest.builder()
.bucket(properties.getBucket())
.key(uploadState.objectKey)
.build()
));
})
// check object metadata
.doOnNext((response) -> {
checkResult(response, "headObject");
})
// delete object
.flatMap((response) -> Mono.just(client.deleteObject(
software.amazon.awssdk.services.s3.model.DeleteObjectRequest.builder()
.bucket(properties.getBucket())
.key(uploadState.objectKey)
.build()
)))
.doOnNext((response) -> checkResult(response, "deleteObject"))
.then();
},
SdkAutoCloseable::close)
.onErrorMap(S3ExceptionHandler::map);
}
private Flux<DataBuffer> readImage() {
DefaultResourceLoader resourceLoader = new DefaultResourceLoader(this.getClass()
.getClassLoader());
String path = PathUtils.combinePath("validation.jpg");
String simplifyPath = StringUtils.cleanPath(path);
Resource resource = resourceLoader.getResource(simplifyPath);
return DataBufferUtils.read(resource, new DefaultDataBufferFactory(), 1024);
}
}

View File

@@ -1,30 +1,22 @@
package run.halo.s3os;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.halo.app.core.extension.attachment.Attachment;
import run.halo.app.core.extension.attachment.Policy;
import run.halo.app.extension.ReactiveExtensionClient;
import run.halo.app.plugin.ApiVersion;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
@ApiVersion("s3os.halo.run/v1alpha1")
@RestController
@RequiredArgsConstructor
public class S3LinkController {
private final S3LinkService s3LinkService;
private final ReactiveExtensionClient client;
/**
* Map of linking file, used as a lock, key is policyName/objectKey, value is policyName/objectKey.
*/
private final Map<String, Object> linkingFile = new ConcurrentHashMap<>();
@GetMapping("/policies/s3")
public Flux<Policy> listS3Policies() {
@@ -36,50 +28,19 @@ public class S3LinkController {
@RequestParam(name = "continuationToken", required = false) String continuationToken,
@RequestParam(name = "continuationObject", required = false) String continuationObject,
@RequestParam(name = "pageSize") Integer pageSize,
@RequestParam(name = "unlinked", required = false, defaultValue = "false")
Boolean unlinked) {
@RequestParam(name = "unlinked", required = false, defaultValue = "false") Boolean unlinked,
@RequestParam(name = "filePrefix", required = false) String filePrefix) {
if (unlinked) {
return s3LinkService.listObjectsUnlinked(policyName, continuationToken,
continuationObject, pageSize);
continuationObject, pageSize, filePrefix);
} else {
return s3LinkService.listObjects(policyName, continuationToken, pageSize);
return s3LinkService.listObjects(policyName, continuationToken, pageSize, filePrefix);
}
}
@PostMapping("/attachments/link")
public Mono<LinkResult> addAttachmentRecord(@RequestBody LinkRequest linkRequest) {
return Flux.fromIterable(linkRequest.getObjectKeys())
.filter(objectKey -> linkingFile.put(linkRequest.getPolicyName() + "/" + objectKey,
linkRequest.getPolicyName() + "/" + objectKey) == null)
.collectList()
.flatMap(operableObjectKeys -> client.list(Attachment.class,
attachment -> Objects.equals(attachment.getSpec().getPolicyName(),
linkRequest.getPolicyName())
&& StringUtils.isNotEmpty(attachment.getMetadata().getAnnotations()
.get(S3OsAttachmentHandler.OBJECT_KEY))
&& linkRequest.getObjectKeys().contains(attachment.getMetadata()
.getAnnotations().get(S3OsAttachmentHandler.OBJECT_KEY)),
null)
.collectList()
.flatMap(existingAttachments -> Flux.fromIterable(linkRequest.getObjectKeys())
.flatMap((objectKey) -> {
if (operableObjectKeys.contains(objectKey) && existingAttachments.stream()
.noneMatch(attachment -> Objects.equals(
attachment.getMetadata().getAnnotations().get(
S3OsAttachmentHandler.OBJECT_KEY), objectKey))) {
return s3LinkService
.addAttachmentRecord(linkRequest.getPolicyName(), objectKey)
.onErrorResume((throwable) -> Mono.just(
new LinkResult.LinkResultItem(objectKey, false,
throwable.getMessage())));
} else {
return Mono.just(new LinkResult.LinkResultItem(objectKey, false,
"附件库中已存在该对象"));
}
})
.doOnNext(linkResultItem -> linkingFile.remove(
linkRequest.getPolicyName() + "/" + linkResultItem.getObjectKey()))
.collectList()
.map(LinkResult::new)));
return s3LinkService.addAttachmentRecords(linkRequest.getPolicyName(),
linkRequest.getObjectKeys(), linkRequest.getGroupName());
}
}

View File

@@ -1,6 +1,7 @@
package run.halo.s3os;
import java.util.Set;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import run.halo.app.core.extension.attachment.Policy;
@@ -9,10 +10,12 @@ public interface S3LinkService {
Flux<Policy> listS3Policies();
Mono<S3ListResult> listObjects(String policyName, String continuationToken,
Integer pageSize);
Integer pageSize, String filePrefix);
Mono<LinkResult.LinkResultItem> addAttachmentRecord(String policyName, String objectKey);
Mono<LinkResult> addAttachmentRecords(String policyName, Set<String> objectKeys,
String groupName);
Mono<S3ListResult> listObjectsUnlinked(String policyName, String continuationToken,
String continuationObject, Integer pageSize);
String continuationObject, Integer pageSize,
String filePrefix);
}

View File

@@ -3,7 +3,11 @@ package run.halo.s3os;
import static run.halo.s3os.S3OsAttachmentHandler.OBJECT_KEY;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
@@ -11,6 +15,7 @@ import java.util.stream.Collectors;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.data.domain.Sort;
import org.springframework.http.HttpStatus;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
@@ -23,7 +28,11 @@ import reactor.core.scheduler.Schedulers;
import run.halo.app.core.extension.attachment.Attachment;
import run.halo.app.core.extension.attachment.Policy;
import run.halo.app.extension.ConfigMap;
import run.halo.app.extension.ListOptions;
import run.halo.app.extension.MetadataUtil;
import run.halo.app.extension.ReactiveExtensionClient;
import run.halo.app.extension.index.query.QueryFactory;
import run.halo.app.extension.router.selector.FieldSelector;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.model.HeadObjectRequest;
import software.amazon.awssdk.services.s3.model.ListObjectsV2Request;
@@ -37,16 +46,21 @@ public class S3LinkServiceImpl implements S3LinkService {
private final ReactiveExtensionClient client;
private final S3OsAttachmentHandler handler;
/**
* Map of linking file, used as a lock, key is policyName/objectKey, value is policyName/objectKey.
*/
private final Map<String, Object> linkingFile = new ConcurrentHashMap<>();
@Override
public Flux<Policy> listS3Policies() {
return client.list(Policy.class, (policy) -> "s3os".equals(
policy.getSpec().getTemplateName()), null);
policy.getSpec().getTemplateName()), Comparator.naturalOrder());
}
@Override
public Mono<S3ListResult> listObjects(String policyName, String continuationToken,
Integer pageSize) {
Integer pageSize, String filePrefix) {
return client.fetch(Policy.class, policyName)
.flatMap((policy) -> {
var configMapName = policy.getSpec().getConfigMapName();
@@ -56,11 +70,11 @@ public class S3LinkServiceImpl implements S3LinkService {
var properties = handler.getProperties(configMap);
var finalLocation = FilePathUtils.getFilePathByPlaceholder(properties.getLocation());
return Mono.using(() -> handler.buildS3Client(properties),
// 执行 listObjects
(s3Client) -> Mono.fromCallable(
() -> s3Client.listObjectsV2(ListObjectsV2Request.builder()
.bucket(properties.getBucket())
.prefix(StringUtils.isNotEmpty(finalLocation)
? finalLocation + "/" : null)
.prefix(buildPrefix(finalLocation, filePrefix))
.delimiter("/")
.maxKeys(pageSize)
.continuationToken(StringUtils.isNotEmpty(continuationToken)
@@ -69,13 +83,16 @@ public class S3LinkServiceImpl implements S3LinkService {
S3Client::close)
.flatMap(listObjectsV2Response -> {
List<S3Object> contents = listObjectsV2Response.contents();
// 过滤掉目录并转换为ObjectVo
var objectVos = contents
.stream().map(S3ListResult.ObjectVo::fromS3Object)
.filter(objectVo -> !objectVo.getKey().endsWith("/"))
.collect(Collectors.toMap(S3ListResult.ObjectVo::getKey, o -> o));
return client.list(Attachment.class,
attachment -> policyName.equals(
attachment.getSpec().getPolicyName()), null)
// 获取已经关联的附件并标记
ListOptions listOptions = new ListOptions();
listOptions.setFieldSelector(
FieldSelector.of(QueryFactory.equal("spec.policyName", policyName)));
return client.listAll(Attachment.class, listOptions, Sort.unsorted())
.doOnNext(attachment -> {
S3ListResult.ObjectVo objectVo =
objectVos.get(attachment.getMetadata().getAnnotations()
@@ -95,9 +112,63 @@ public class S3LinkServiceImpl implements S3LinkService {
.onErrorMap(S3ExceptionHandler::map);
}
@Override
public Mono<LinkResult> addAttachmentRecords(String policyName, Set<String> objectKeys, String groupName) {
return getOperableObjectKeys(objectKeys, policyName)
.flatMap(operableObjectKeys -> getExistingAttachments(objectKeys, policyName)
.flatMap(existingAttachments -> getLinkResultItems(objectKeys, operableObjectKeys,
existingAttachments, policyName, groupName)
.collectList()
.map(LinkResult::new)));
}
private Mono<Set<String>> getOperableObjectKeys(Set<String> objectKeys, String policyName) {
return Flux.fromIterable(objectKeys)
.filter(objectKey ->
linkingFile.put(policyName + "/" + objectKey, policyName + "/" + objectKey) == null)
.collect(Collectors.toSet());
}
private Mono<Set<String>> getExistingAttachments(Set<String> objectKeys,
String policyName) {
ListOptions listOptions = new ListOptions();
listOptions.setFieldSelector(
FieldSelector.of(QueryFactory.equal("spec.policyName", policyName)));
return client.listAll(Attachment.class, listOptions, Sort.unsorted())
.filter(attachment -> StringUtils.isNotBlank(
MetadataUtil.nullSafeAnnotations(attachment).get(S3OsAttachmentHandler.OBJECT_KEY))
&& objectKeys.contains(
MetadataUtil.nullSafeAnnotations(attachment).get(S3OsAttachmentHandler.OBJECT_KEY)))
.map(attachment -> MetadataUtil.nullSafeAnnotations(attachment)
.get(S3OsAttachmentHandler.OBJECT_KEY))
.collect(Collectors.toSet());
}
private Flux<LinkResult.LinkResultItem> getLinkResultItems(Set<String> objectKeys,
Set<String> operableObjectKeys,
Set<String> existingAttachments,
String policyName,
String groupName) {
return Flux.fromIterable(objectKeys)
.flatMap((objectKey) -> {
if (operableObjectKeys.contains(objectKey) &&
!existingAttachments.contains(objectKey)) {
return addAttachmentRecord(policyName, objectKey, groupName)
.onErrorResume((throwable) -> Mono.just(
new LinkResult.LinkResultItem(objectKey, false,
throwable.getMessage())));
} else {
return Mono.just(
new LinkResult.LinkResultItem(objectKey, false, "附件库中已存在该对象"));
}
})
.doFinally(signalType -> operableObjectKeys.forEach(
objectKey -> linkingFile.remove(policyName + "/" + objectKey)));
}
@Override
public Mono<S3ListResult> listObjectsUnlinked(String policyName, String continuationToken,
String continuationObject, Integer pageSize) {
String continuationObject, Integer pageSize, String filePrefix) {
// TODO 优化成查一次数据库
return Mono.defer(() -> {
List<S3ListResult.ObjectVo> s3Objects = new ArrayList<>();
@@ -106,7 +177,8 @@ public class S3LinkServiceImpl implements S3LinkService {
return Flux.defer(() -> Flux.just(
new TokenState(null, currToken.get() == null ? "" : currToken.get())))
.flatMap(tokenState -> listObjects(policyName, tokenState.nextToken, pageSize))
.flatMap(tokenState -> listObjects(policyName, tokenState.nextToken,
pageSize, filePrefix))
.flatMap(s3ListResult -> {
var filteredObjects = s3ListResult.getObjects();
if (!continuationObjectMatched.get()) {
@@ -151,10 +223,8 @@ public class S3LinkServiceImpl implements S3LinkService {
record TokenState(String currToken, String nextToken) {
}
@Override
public Mono<LinkResult.LinkResultItem> addAttachmentRecord(String policyName,
String objectKey) {
String objectKey, String groupName) {
return authenticationConsumer(authentication -> client.fetch(Policy.class, policyName)
.flatMap((policy) -> {
var configMapName = policy.getSpec().getConfigMapName();
@@ -186,6 +256,9 @@ public class S3LinkServiceImpl implements S3LinkService {
}
spec.setOwnerName(authentication.getName());
spec.setPolicyName(policyName);
if (StringUtils.isNotBlank(groupName)){
spec.setGroupName(groupName);
}
})
.flatMap(client::create)
.thenReturn(new LinkResult.LinkResultItem(objectKey, true, null));
@@ -203,4 +276,18 @@ public class S3LinkServiceImpl implements S3LinkService {
.flatMap(func);
}
String buildPrefix(String finalLocation, String filePrefix) {
if (StringUtils.isBlank(finalLocation) && StringUtils.isBlank(filePrefix)) {
return null;
}
StringBuilder sb = new StringBuilder();
if (StringUtils.isNotBlank(finalLocation)) {
sb.append(finalLocation).append("/");
}
if (StringUtils.isNotBlank(filePrefix)) {
sb.append(filePrefix);
}
return sb.toString();
}
}

View File

@@ -390,8 +390,8 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
SdkAutoCloseable::close);
}
private Mono<UploadState> checkFileExistsAndRename(UploadState uploadState,
S3Client s3client) {
Mono<UploadState> checkFileExistsAndRename(UploadState uploadState,
S3Client s3client) {
return Mono.defer(() -> {
// deduplication of uploading files
if (uploadingFile.put(uploadState.getUploadingMapKey(),
@@ -437,8 +437,8 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
}
private Mono<CompletedPart> uploadPart(UploadState uploadState, ByteBuffer buffer,
S3Client s3client) {
Mono<CompletedPart> uploadPart(UploadState uploadState, ByteBuffer buffer,
S3Client s3client) {
final int partNumber = ++uploadState.partCounter;
return Mono.just(s3client.uploadPart(UploadPartRequest.builder()
.bucket(uploadState.properties.getBucket())
@@ -457,7 +457,7 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
});
}
private static void checkResult(SdkResponse result, String operation) {
static void checkResult(SdkResponse result, String operation) {
log.info("operation: {}, result: {}", operation, result);
if (result.sdkHttpResponse() == null || !result.sdkHttpResponse().isSuccessful()) {
log.error("Failed to upload object, response: {}", result.sdkHttpResponse());
@@ -465,7 +465,7 @@ public class S3OsAttachmentHandler implements AttachmentHandler {
}
}
private static ByteBuffer concatBuffers(List<DataBuffer> buffers) {
static ByteBuffer concatBuffers(List<DataBuffer> buffers) {
int partSize = 0;
for (DataBuffer b : buffers) {
partSize += b.readableByteCount();

View File

@@ -1,8 +1,8 @@
package run.halo.s3os;
import org.pf4j.PluginWrapper;
import org.springframework.stereotype.Component;
import run.halo.app.plugin.BasePlugin;
import run.halo.app.plugin.PluginContext;
/**
* @author johnniang
@@ -11,8 +11,8 @@ import run.halo.app.plugin.BasePlugin;
@Component
public class S3OsPlugin extends BasePlugin {
public S3OsPlugin(PluginWrapper wrapper) {
super(wrapper);
public S3OsPlugin(PluginContext pluginContext) {
super(pluginContext);
}
@Override

View File

@@ -3,7 +3,7 @@ kind: PolicyTemplate
metadata:
name: s3os
spec:
displayName: S3 Object Storage
displayName: S3 对象存储
settingName: s3os-policy-template-setting
---
apiVersion: v1alpha1
@@ -14,130 +14,134 @@ spec:
forms:
- group: default
formSchema:
- $formkit: text
name: bucket
label: Bucket 桶名称
validation: required
- $formkit: select
name: endpointProtocol
label: Endpoint 访问协议
options:
- label: HTTPS
value: https
- label: HTTP
value: http
validation: required
- $formkit: select
name: enablePathStyleAccess
label: Endpoint 访问风格
options:
- label: Virtual Hosted Style
value: false
- label: Path Style
value: true
value: false
validation: required
- $formkit: text
name: endpoint
label: EndPoint
placeholder: 请填写不带bucket-name的Endpoint
validation: required
help: 协议头请在上方设置,此处无需以"http://"或"https://"开头,系统会自动拼接
- $formkit: password
name: accessKey
label: Access Key ID
placeholder: 存储桶用户标识(用户名)
validation: required
- $formkit: password
name: accessSecret
label: Access Key Secret
placeholder: 存储桶密钥(密码)
validation: required
- $formkit: text
name: region
label: Region
placeholder: 如不填写,则默认为"Auto"
help: 若Region为Auto无法使用才需要填写对应Region
- $formkit: text
name: location
label: 上传目录
placeholder: 如不填写,则默认上传到根目录
help: 支持的占位符请查阅https://github.com/halo-dev/plugin-s3#上传目录
- $formkit: select
name: randomFilenameMode
label: 上传时重命名文件方式
options:
- label: 保留原文件名
value: none
- label: 自定义(请在下方输入自定义模板)
value: custom
- label: 使用UUID
value: uuid
- label: 使用毫秒时间戳
value: timestampMs
- label: 使用原文件名 + 随机字母
value: withString
- label: 使用日期 + 随机字母
value: dateWithString
- label: 使用日期时间 + 随机字母
value: datetimeWithString
- label: 使用随机字母
value: string
validation: required
- $formkit: number
name: randomStringLength
key: randomStringLength
label: 随机字母长度
min: 4
max: 16
if: "$randomFilenameMode == 'dateWithString' || $randomFilenameMode == 'datetimeWithString' || $randomFilenameMode == 'withString' || $randomFilenameMode == 'string'"
help: 支持4~16位, 默认为8位
- $formkit: text
name: customTemplate
key: customTemplate
label: 自定义文件名模板
if: "$randomFilenameMode == 'custom'"
value: "${origin-filename}"
help: 支持的占位符请查阅https://github.com/halo-dev/plugin-s3#自定义文件名模板
- $formkit: select
name: duplicateFilenameHandling
label: 重复文件名处理方式
options:
- label: 加随机字母数字后缀
value: randomAlphanumeric
- label: 加随机字母后缀
value: randomAlphabetic
- label: 报错不上传
value: exception
validation: required
- $formkit: select
name: protocol
label: 绑定域名协议
options:
- label: HTTPS
value: https
- label: HTTP
value: http
validation: required
- $formkit: text
name: domain
label: 绑定域名CDN域名
placeholder: 如不设置,那么将使用 Bucket + EndPoint 作为域名
help: 协议头请在上方设置,此处无需以"http://"或"https://"开头,系统会自动拼接
- $formkit: repeater
name: urlSuffixes
label: 网址后缀
help: 用于对指定文件类型的网址添加后缀处理参数,优先级从上到下只取第一个匹配项
value: [ ]
min: 0
- $formkit: verificationForm
action: "/apis/s3os.halo.run/v1alpha1/policies/s3/validation"
label: 对象存储验证
children:
- $formkit: text
name: fileSuffix
label: 文件后缀
placeholder: 以半角逗号分隔例如jpg,jpeg,png,gif
name: bucket
label: Bucket 桶名称
validation: required
- $formkit: select
name: endpointProtocol
label: Endpoint 访问协议
options:
- label: HTTPS
value: https
- label: HTTP
value: http
validation: required
- $formkit: select
name: enablePathStyleAccess
label: Endpoint 访问风格
options:
- label: Virtual Hosted Style
value: false
- label: Path Style
value: true
value: false
validation: required
- $formkit: text
name: urlSuffix
name: endpoint
label: EndPoint
placeholder: 请填写不带bucket-name的Endpoint
validation: required
help: 协议头请在上方设置,此处无需以"http://"或"https://"开头,系统会自动拼接
- $formkit: password
name: accessKey
label: Access Key ID
placeholder: 存储桶用户标识(用户名)
validation: required
- $formkit: password
name: accessSecret
label: Access Key Secret
placeholder: 存储桶密钥(密码)
validation: required
- $formkit: text
name: region
label: Region
placeholder: 如不填写,则默认为"Auto"
help: 若Region为Auto无法使用才需要填写对应Region
- $formkit: text
name: location
label: 上传目录
placeholder: 如不填写,则默认上传到根目录
help: 支持的占位符请查阅https://github.com/halo-dev/plugin-s3#上传目录
- $formkit: select
name: randomFilenameMode
label: 上传时重命名文件方式
options:
- label: 保留原文件名
value: none
- label: 自定义(请在下方输入自定义模板)
value: custom
- label: 使用UUID
value: uuid
- label: 使用毫秒时间戳
value: timestampMs
- label: 使用原文件名 + 随机字母
value: withString
- label: 使用日期 + 随机字母
value: dateWithString
- label: 使用日期时间 + 随机字母
value: datetimeWithString
- label: 使用随机字母
value: string
validation: required
- $formkit: number
name: randomStringLength
key: randomStringLength
label: 随机字母长度
min: 4
max: 16
if: "$randomFilenameMode == 'dateWithString' || $randomFilenameMode == 'datetimeWithString' || $randomFilenameMode == 'withString' || $randomFilenameMode == 'string'"
help: 支持4~16位, 默认为8位
- $formkit: text
name: customTemplate
key: customTemplate
label: 自定义文件名模板
if: "$randomFilenameMode == 'custom'"
value: "${origin-filename}"
help: 支持的占位符请查阅https://github.com/halo-dev/plugin-s3#自定义文件名模板
- $formkit: select
name: duplicateFilenameHandling
label: 重复文件名处理方式
options:
- label: 加随机字母数字后缀
value: randomAlphanumeric
- label: 加随机字母后缀
value: randomAlphabetic
- label: 报错不上传
value: exception
validation: required
- $formkit: select
name: protocol
label: 绑定域名协议
options:
- label: HTTPS
value: https
- label: HTTP
value: http
validation: required
- $formkit: text
name: domain
label: 绑定域名CDN域名
placeholder: 如不设置,那么将使用 Bucket + EndPoint 作为域名
help: 协议头请在上方设置,此处无需以"http://"或"https://"开头,系统会自动拼接
- $formkit: repeater
name: urlSuffixes
label: 网址后缀
placeholder: 例如:?imageMogr2/format/webp
validation: required
help: 用于对指定文件类型的网址添加后缀处理参数,优先级从上到下只取第一个匹配项
value: [ ]
min: 0
children:
- $formkit: text
name: fileSuffix
label: 文件后缀
placeholder: 以半角逗号分隔例如jpg,jpeg,png,gif
validation: required
- $formkit: text
name: urlSuffix
label: 网址后缀
placeholder: 例如:?imageMogr2/format/webp
validation: required

View File

@@ -39,3 +39,17 @@ rules:
- apiGroups: [ "s3os.halo.run" ]
resources: [ "attachments" ]
verbs: [ "delete" ]
---
apiVersion: v1alpha1
kind: "Role"
metadata:
name: role-template-s3os-policy-config-validation
labels:
halo.run/role-template: "true"
halo.run/hidden: "true"
rbac.authorization.halo.run/aggregate-to-role-template-manage-configmaps: "true"
rules:
- apiGroups: ["s3os.halo.run"]
resources: ["policies/validation"]
resourceNames: ["s3"]
verbs: [ "create" ]

View File

@@ -7,8 +7,5 @@ spec:
- group: basic
label: 使用提示
formSchema:
- $formkit: text
help: 请前往 “附件 - 存储策略” 添加策略
label: 此处不用设置,请前往 “附件 - 存储策略” 添加策略
name: text
placeholder: 此处不用设置,请前往 “附件 - 存储策略” 添加策略
- $el: p
children: 请前往 “附件 - 存储策略” 添加策略

View File

@@ -4,14 +4,16 @@ metadata:
name: PluginS3ObjectStorage
spec:
enabled: true
requires: ">=2.12.0"
requires: ">=2.17.0"
author:
name: Halo OSS Team
name: Halo
website: https://github.com/halo-dev
logo: data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAAAXNSR0IArs4c6QAABUdJREFUeF7tmmtoXFUQx3+zMYGi/RJRULRFsL6oim2klVK0CrVqKxjoJ0Vt1bR7t6lURagiFlGpFPogydklVo1i/VB84QMfqFijpflQrI+IYj7FF+0HMbUEI82O3NNtzG6y956bvXd3IXvgksCd+c/M/8w598ycFWb5kFkePw0CGhkwyxloLIFZngCNTbCxBBpLoI4Y0A6aydNKC62kaAXGSDHCv4zQzIh0MRa3uzVdAppmMSmWoVyL0IZyWUiA3wL7gI/FcCQOMmpCQCHwDpSOCoIYQOmWLK9WgFHdr4Bu4wyOsR14uBKni3SFdxhnl+T4fCaYVcsAzbCEPNsRbpiJow46u8TwkINcCX9RNWYgr2nWIrwAzJ2BehSVAVpYJbv5y1Up8QwoBL/f1aGY5JaJ4aALVqIEqMc24EkXRxKQmSeGX8JwEyNAPR4AesMcSPD9ECdpk15GgmwkQoB2spxxPgWaEwzQBfptMdxRfQI8PgJWuniYuIyyQbLlMzH2DFCPDUAu8cDcDRwWQ1s58VgJ0E7OYZyvgAXu/lVBMiAL4iXA4z5gbxVCimpiQAxLp1OKl4AMfSj3RPWuKvJ5FkmOr0ttxUuAx9/AWVUJKKoR5QnJ8nRsBOh65tJiy9nFYJ+fwB586nUcEsN1FROgHncDG2EqWIWR/wpcUCFGsPooc6SPfyYLOS8BzbAI5RlgVQJObrXdH9iZAPb/kCkul25+jEyAejboDxJyLiMG42Orx2fAioTs+LC3iOHDSARohs0oexJxStgtPWw5jZ34IUpJS7b4kBa4BDTDTSifJBI8vC+G1ZOxdQtzGGMIOD8hm1vF2I7UxAgmwLNpn8SaHyTPjZLjWGmg6tl9YCIrYiVCuVOyvOZEQGG3fzlWB06BjZJipXTbI/OUoWmuQvgmAbs+5HIxfOlKwCFgSQKOrBNDXxCuerwH3Ba77ZPMl16GQwnQjSwkxXexO6A8JdnwDpF6tANvxG1fzNQu+LR7QEKtrFfEuNcJ6vEzcHGMJEzZdH3scgRkC6e9eOwr/Qi3iuGEK6B6PAo85yofKid40oMfV9EoR8CbENxKCjVYvNCWSg8DUXQKn8TRKDqBstOs/6AMiLelVaYUDQtO0zyPcH+YnMP7d8Vw+3Ry5TLgJeBeB2BXEX8mDwDHEUZQWzafEBNcPca2FwlrpMd+WaaM6QnI8CyKX6AkN/KsmHyfZ9voQjfKUbDPOMoCxF6TVzLKzn75JZBmOcIXlVgN0y39JGka/yOVDtOL/D5g9ssS4L9Qz5aNl0Y26KZwRAzXTBZVj8PAIjd1Z6ntYoIzuWwtoBkeK9T/ztacBUurwA1cQRODzvpugvvEcFeYaHkCHuFMRvGPwwvDQCK+P0qexZLjt9N6mmE9am+P4xnKn5LlbBew4GowzTqEF12AnGXytEuOtyaC30aKY7YRcr0zRrDg92K40hUrtCWmGfajrHUFDJHzf9tzc8na9zu1j8eCL/RKj72Zch6hBPhI6tEFbHJGnV5wSEzxjVGMrbZBlB2SJXL57kRAgQS/G7wDODcyEUKX9LC5ZOb9+wO/lV5J9+c4sIsmdkoX/v+RhzMBloRNXESeB8E+4UNtSbtHsvSXCqt/1oB2xNYc88PBiiT8uuIgTeyVLn6IqFskHomAiY0rwyUoa1BWI3YGzyu8+wPld1K8Tp5+yeL/ri90aCdXM26JuBCYN/GcOjYPIwzbv3CYJg5IF/4dQixjRgTEYrlOQBoE1MlE1MyNRgbUjPo6MdzIgDqZiJq50ciAmlFfJ4YbGVAnE1EzN2Z9BvwH8mZfUOuuxhIAAAAASUVORK5CYII=
settingName: s3os-settings
configMapName: s3os-configMap
homepage: https://github.com/halo-dev/plugin-s3
homepage: https://www.halo.run/store/apps/app-Qxhpp
repo: https://github.com/halo-dev/plugin-s3
issues: https://github.com/halo-dev/plugin-s3/issues
displayName: "对象存储Amazon S3 协议)"
description: "提供兼容 Amazon S3 协议的对象存储策略,兼容阿里云、腾讯云、七牛云等"
license:

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB