Merge pull request #6661 from guqing/refactor/setting-config-update

feat: support JSON-based retrieval and update for theme and plugin configs
pull/6703/head^2
John Niang 2024-09-28 18:17:32 +08:00 committed by GitHub
commit a4c906706f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
15 changed files with 1073 additions and 93 deletions

View File

@ -2871,7 +2871,7 @@
}, },
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/config": { "/apis/api.console.halo.run/v1alpha1/plugins/{name}/config": {
"get": { "get": {
"description": "Fetch configMap of plugin by configured configMapName.", "description": "Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0",
"operationId": "fetchPluginConfig", "operationId": "fetchPluginConfig",
"parameters": [ "parameters": [
{ {
@ -2900,7 +2900,8 @@
] ]
}, },
"put": { "put": {
"description": "Update the configMap of plugin setting.", "deprecated": true,
"description": "Update the configMap of plugin setting, it is deprecated since 2.20.0",
"operationId": "updatePluginConfig", "operationId": "updatePluginConfig",
"parameters": [ "parameters": [
{ {
@ -2939,6 +2940,70 @@
] ]
} }
}, },
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config": {
"get": {
"description": "Fetch converted json config of plugin by configured configMapName.",
"operationId": "fetchPluginJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"default": {
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
},
"description": "default response"
}
},
"tags": [
"PluginV1alpha1Console"
]
},
"put": {
"description": "Update the config of plugin setting.",
"operationId": "updatePluginJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {},
"description": "No Content"
}
},
"tags": [
"PluginV1alpha1Console"
]
}
},
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state": { "/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state": {
"put": { "put": {
"description": "Change the running state of a plugin by name.", "description": "Change the running state of a plugin by name.",
@ -4545,7 +4610,8 @@
}, },
"/apis/api.console.halo.run/v1alpha1/themes/{name}/config": { "/apis/api.console.halo.run/v1alpha1/themes/{name}/config": {
"get": { "get": {
"description": "Fetch configMap of theme by configured configMapName.", "deprecated": true,
"description": "Fetch configMap of theme by configured configMapName. It is deprecated.",
"operationId": "fetchThemeConfig", "operationId": "fetchThemeConfig",
"parameters": [ "parameters": [
{ {
@ -4574,7 +4640,8 @@
] ]
}, },
"put": { "put": {
"description": "Update the configMap of theme setting.", "deprecated": true,
"description": "Update the configMap of theme setting. It is deprecated.",
"operationId": "updateThemeConfig", "operationId": "updateThemeConfig",
"parameters": [ "parameters": [
{ {
@ -4637,6 +4704,70 @@
] ]
} }
}, },
"/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config": {
"get": {
"description": "Fetch converted json config of theme by configured configMapName.",
"operationId": "fetchThemeJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"default": {
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
},
"description": "default response"
}
},
"tags": [
"ThemeV1alpha1Console"
]
},
"put": {
"description": "Update the configMap of theme setting.",
"operationId": "updateThemeJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {},
"description": "No Content"
}
},
"tags": [
"ThemeV1alpha1Console"
]
}
},
"/apis/api.console.halo.run/v1alpha1/themes/{name}/reload": { "/apis/api.console.halo.run/v1alpha1/themes/{name}/reload": {
"put": { "put": {
"description": "Reload theme setting.", "description": "Reload theme setting.",

View File

@ -738,7 +738,7 @@
}, },
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/config": { "/apis/api.console.halo.run/v1alpha1/plugins/{name}/config": {
"get": { "get": {
"description": "Fetch configMap of plugin by configured configMapName.", "description": "Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0",
"operationId": "fetchPluginConfig", "operationId": "fetchPluginConfig",
"parameters": [ "parameters": [
{ {
@ -767,7 +767,8 @@
] ]
}, },
"put": { "put": {
"description": "Update the configMap of plugin setting.", "deprecated": true,
"description": "Update the configMap of plugin setting, it is deprecated since 2.20.0",
"operationId": "updatePluginConfig", "operationId": "updatePluginConfig",
"parameters": [ "parameters": [
{ {
@ -806,6 +807,70 @@
] ]
} }
}, },
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config": {
"get": {
"description": "Fetch converted json config of plugin by configured configMapName.",
"operationId": "fetchPluginJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"default": {
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
},
"description": "default response"
}
},
"tags": [
"PluginV1alpha1Console"
]
},
"put": {
"description": "Update the config of plugin setting.",
"operationId": "updatePluginJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {},
"description": "No Content"
}
},
"tags": [
"PluginV1alpha1Console"
]
}
},
"/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state": { "/apis/api.console.halo.run/v1alpha1/plugins/{name}/plugin-state": {
"put": { "put": {
"description": "Change the running state of a plugin by name.", "description": "Change the running state of a plugin by name.",
@ -2412,7 +2477,8 @@
}, },
"/apis/api.console.halo.run/v1alpha1/themes/{name}/config": { "/apis/api.console.halo.run/v1alpha1/themes/{name}/config": {
"get": { "get": {
"description": "Fetch configMap of theme by configured configMapName.", "deprecated": true,
"description": "Fetch configMap of theme by configured configMapName. It is deprecated.",
"operationId": "fetchThemeConfig", "operationId": "fetchThemeConfig",
"parameters": [ "parameters": [
{ {
@ -2441,7 +2507,8 @@
] ]
}, },
"put": { "put": {
"description": "Update the configMap of theme setting.", "deprecated": true,
"description": "Update the configMap of theme setting. It is deprecated.",
"operationId": "updateThemeConfig", "operationId": "updateThemeConfig",
"parameters": [ "parameters": [
{ {
@ -2504,6 +2571,70 @@
] ]
} }
}, },
"/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config": {
"get": {
"description": "Fetch converted json config of theme by configured configMapName.",
"operationId": "fetchThemeJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"default": {
"content": {
"*/*": {
"schema": {
"type": "object"
}
}
},
"description": "default response"
}
},
"tags": [
"ThemeV1alpha1Console"
]
},
"put": {
"description": "Update the configMap of theme setting.",
"operationId": "updateThemeJsonConfig",
"parameters": [
{
"in": "path",
"name": "name",
"required": true,
"schema": {
"type": "string"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object"
}
}
},
"required": true
},
"responses": {
"204": {
"content": {},
"description": "No Content"
}
},
"tags": [
"ThemeV1alpha1Console"
]
}
},
"/apis/api.console.halo.run/v1alpha1/themes/{name}/reload": { "/apis/api.console.halo.run/v1alpha1/themes/{name}/reload": {
"put": { "put": {
"description": "Reload theme setting.", "description": "Reload theme setting.",

View File

@ -17,6 +17,7 @@ import static run.halo.app.extension.index.query.QueryFactory.or;
import static run.halo.app.extension.router.QueryParamBuildUtil.sortParameter; import static run.halo.app.extension.router.QueryParamBuildUtil.sortParameter;
import static run.halo.app.infra.utils.FileUtils.deleteFileSilently; import static run.halo.app.infra.utils.FileUtils.deleteFileSilently;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
@ -41,6 +42,7 @@ import org.springframework.core.io.buffer.DataBuffer;
import org.springframework.dao.OptimisticLockingFailureException; import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.data.domain.Sort; import org.springframework.data.domain.Sort;
import org.springframework.http.CacheControl; import org.springframework.http.CacheControl;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.http.codec.multipart.FilePart; import org.springframework.http.codec.multipart.FilePart;
import org.springframework.http.codec.multipart.FormFieldPart; import org.springframework.http.codec.multipart.FormFieldPart;
@ -61,6 +63,7 @@ import reactor.util.retry.Retry;
import run.halo.app.core.extension.Plugin; import run.halo.app.core.extension.Plugin;
import run.halo.app.core.extension.Setting; import run.halo.app.core.extension.Setting;
import run.halo.app.core.extension.endpoint.CustomEndpoint; import run.halo.app.core.extension.endpoint.CustomEndpoint;
import run.halo.app.core.user.service.SettingConfigService;
import run.halo.app.extension.ConfigMap; import run.halo.app.extension.ConfigMap;
import run.halo.app.extension.ListOptions; import run.halo.app.extension.ListOptions;
import run.halo.app.extension.ReactiveExtensionClient; import run.halo.app.extension.ReactiveExtensionClient;
@ -81,6 +84,8 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
private final ReactiveUrlDataBufferFetcher reactiveUrlDataBufferFetcher; private final ReactiveUrlDataBufferFetcher reactiveUrlDataBufferFetcher;
private final SettingConfigService settingConfigService;
private final WebProperties webProperties; private final WebProperties webProperties;
private final Scheduler scheduler = Schedulers.boundedElastic(); private final Scheduler scheduler = Schedulers.boundedElastic();
@ -92,10 +97,12 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
public PluginEndpoint(ReactiveExtensionClient client, public PluginEndpoint(ReactiveExtensionClient client,
PluginService pluginService, PluginService pluginService,
ReactiveUrlDataBufferFetcher reactiveUrlDataBufferFetcher, ReactiveUrlDataBufferFetcher reactiveUrlDataBufferFetcher,
SettingConfigService settingConfigService,
WebProperties webProperties) { WebProperties webProperties) {
this.client = client; this.client = client;
this.pluginService = pluginService; this.pluginService = pluginService;
this.reactiveUrlDataBufferFetcher = reactiveUrlDataBufferFetcher; this.reactiveUrlDataBufferFetcher = reactiveUrlDataBufferFetcher;
this.settingConfigService = settingConfigService;
this.webProperties = webProperties; this.webProperties = webProperties;
} }
@ -158,9 +165,9 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
.content(contentBuilder().mediaType(MediaType.MULTIPART_FORM_DATA_VALUE) .content(contentBuilder().mediaType(MediaType.MULTIPART_FORM_DATA_VALUE)
.schema(schemaBuilder().implementation(InstallRequest.class)))) .schema(schemaBuilder().implementation(InstallRequest.class))))
) )
.PUT("plugins/{name}/config", this::updatePluginConfig, .PUT("plugins/{name}/json-config", this::updatePluginJsonConfig,
builder -> builder.operationId("updatePluginConfig") builder -> builder.operationId("updatePluginJsonConfig")
.description("Update the configMap of plugin setting.") .description("Update the config of plugin setting.")
.tag(tag) .tag(tag)
.parameter(parameterBuilder() .parameter(parameterBuilder()
.name("name") .name("name")
@ -168,6 +175,26 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
.required(true) .required(true)
.implementation(String.class) .implementation(String.class)
) )
.requestBody(requestBodyBuilder()
.required(true)
.content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE)
.schema(schemaBuilder().implementation(ObjectNode.class))))
.response(responseBuilder()
.responseCode(String.valueOf(HttpStatus.NO_CONTENT.value()))
.implementation(Void.class))
)
.PUT("plugins/{name}/config", this::updatePluginConfig,
builder -> builder.operationId("updatePluginConfig")
.description(
"Update the configMap of plugin setting, it is deprecated since 2.20.0")
.tag(tag)
.parameter(parameterBuilder()
.name("name")
.in(ParameterIn.PATH)
.required(true)
.implementation(String.class)
)
.deprecated(true)
.requestBody(requestBodyBuilder() .requestBody(requestBodyBuilder()
.required(true) .required(true)
.content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE) .content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE)
@ -244,7 +271,9 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
) )
.GET("plugins/{name}/config", this::fetchPluginConfig, .GET("plugins/{name}/config", this::fetchPluginConfig,
builder -> builder.operationId("fetchPluginConfig") builder -> builder.operationId("fetchPluginConfig")
.description("Fetch configMap of plugin by configured configMapName.") .description(
"Fetch configMap of plugin by configured configMapName. it is deprecated "
+ "since 2.20.0")
.tag(tag) .tag(tag)
.parameter(parameterBuilder() .parameter(parameterBuilder()
.name("name") .name("name")
@ -255,6 +284,20 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
.response(responseBuilder() .response(responseBuilder()
.implementation(ConfigMap.class)) .implementation(ConfigMap.class))
) )
.GET("plugins/{name}/json-config", this::fetchPluginJsonConfig,
builder -> builder.operationId("fetchPluginJsonConfig")
.description(
"Fetch converted json config of plugin by configured configMapName.")
.tag(tag)
.parameter(parameterBuilder()
.name("name")
.in(ParameterIn.PATH)
.required(true)
.implementation(String.class)
)
.response(responseBuilder()
.implementation(ObjectNode.class))
)
.GET("plugin-presets", this::listPresets, .GET("plugin-presets", this::listPresets,
builder -> builder.operationId("ListPluginPresets") builder -> builder.operationId("ListPluginPresets")
.description("List all plugin presets in the system.") .description("List all plugin presets in the system.")
@ -276,6 +319,35 @@ public class PluginEndpoint implements CustomEndpoint, InitializingBean {
.build(); .build();
} }
private Mono<ServerResponse> fetchPluginJsonConfig(ServerRequest request) {
final var name = request.pathVariable("name");
return client.fetch(Plugin.class, name)
.mapNotNull(plugin -> plugin.getSpec().getConfigMapName())
.flatMap(settingConfigService::fetchConfig)
.flatMap(json -> ServerResponse.ok().bodyValue(json));
}
private Mono<ServerResponse> updatePluginJsonConfig(ServerRequest request) {
final var pluginName = request.pathVariable("name");
return client.fetch(Plugin.class, pluginName)
.doOnNext(plugin -> {
String configMapName = plugin.getSpec().getConfigMapName();
if (!StringUtils.hasText(configMapName)) {
throw new ServerWebInputException(
"Unable to complete the request because the plugin configMapName is blank");
}
})
.flatMap(plugin -> {
final String configMapName = plugin.getSpec().getConfigMapName();
return request.bodyToMono(ObjectNode.class)
.switchIfEmpty(
Mono.error(new ServerWebInputException("Required request body is missing")))
.flatMap(configMapJsonData ->
settingConfigService.upsertConfig(configMapName, configMapJsonData));
})
.then(ServerResponse.noContent().build());
}
Mono<ServerResponse> changePluginRunningState(ServerRequest request) { Mono<ServerResponse> changePluginRunningState(ServerRequest request) {
final var name = request.pathVariable("name"); final var name = request.pathVariable("name");
return request.bodyToMono(RunningStateRequest.class) return request.bodyToMono(RunningStateRequest.class)

View File

@ -0,0 +1,19 @@
package run.halo.app.core.user.service;
import com.fasterxml.jackson.databind.node.ObjectNode;
import reactor.core.publisher.Mono;
import run.halo.app.core.extension.Setting;
import run.halo.app.extension.ConfigMap;
/**
* {@link Setting} related {@link ConfigMap} service.
*
* @author guqing
* @since 2.20.0
*/
public interface SettingConfigService {
Mono<Void> upsertConfig(String configMapName, ObjectNode configJsonData);
Mono<ObjectNode> fetchConfig(String configMapName);
}

View File

@ -0,0 +1,57 @@
package run.halo.app.core.user.service.impl;
import com.fasterxml.jackson.databind.node.ObjectNode;
import java.time.Duration;
import lombok.RequiredArgsConstructor;
import org.springframework.dao.OptimisticLockingFailureException;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import reactor.core.publisher.Mono;
import reactor.util.retry.Retry;
import run.halo.app.core.extension.Setting;
import run.halo.app.core.user.service.SettingConfigService;
import run.halo.app.extension.ConfigMap;
import run.halo.app.extension.Metadata;
import run.halo.app.extension.ReactiveExtensionClient;
import run.halo.app.infra.utils.SettingUtils;
/**
* {@link Setting} related {@link ConfigMap} service implementation.
*
* @author guqing
* @since 2.20.0
*/
@Component
@RequiredArgsConstructor
public class SettingConfigServiceImpl implements SettingConfigService {
private final ReactiveExtensionClient client;
@Override
public Mono<Void> upsertConfig(String configMapName, ObjectNode configJsonData) {
Assert.notNull(configMapName, "Config map name must not be null");
Assert.notNull(configJsonData, "Config json data must not be null");
var data = SettingUtils.settingConfigJsonToMap(configJsonData);
return Mono.defer(() -> client.fetch(ConfigMap.class, configMapName)
.flatMap(persisted -> {
persisted.setData(data);
return client.update(persisted);
}))
.retryWhen(Retry.backoff(5, Duration.ofMillis(100))
.filter(OptimisticLockingFailureException.class::isInstance)
)
.switchIfEmpty(Mono.defer(() -> {
var configMap = new ConfigMap();
configMap.setMetadata(new Metadata());
configMap.getMetadata().setName(configMapName);
configMap.setData(data);
return client.create(configMap);
}))
.then();
}
@Override
public Mono<ObjectNode> fetchConfig(String configMapName) {
return client.fetch(ConfigMap.class, configMapName)
.map(SettingUtils::settingConfigToJson);
}
}

View File

@ -127,7 +127,30 @@ public class SettingUtils {
} }
} }
JsonNode mapToJsonNode(Map<String, String> map) { /**
* Convert {@link Setting} related configMap data to JsonNode.
*
* @param configMap {@link ConfigMap} instance
* @return JsonNode
*/
public static ObjectNode settingConfigToJson(ConfigMap configMap) {
if (configMap.getData() == null) {
return JsonNodeFactory.instance.objectNode();
}
return mapToJsonNode(configMap.getData());
}
/**
* Convert the result of {@link #settingConfigToJson(ConfigMap)} in reverse to Map.
*
* @param node JsonNode object
* @return {@link ConfigMap#getData()}
*/
public static Map<String, String> settingConfigJsonToMap(ObjectNode node) {
return jsonNodeToStringMap(node);
}
ObjectNode mapToJsonNode(Map<String, String> map) {
ObjectNode objectNode = JsonNodeFactory.instance.objectNode(); ObjectNode objectNode = JsonNodeFactory.instance.objectNode();
map.forEach((k, v) -> { map.forEach((k, v) -> {
if (isJson(v)) { if (isJson(v)) {

View File

@ -9,6 +9,7 @@ import static org.springdoc.core.fn.builders.schema.Builder.schemaBuilder;
import static org.springframework.http.HttpStatus.NO_CONTENT; import static org.springframework.http.HttpStatus.NO_CONTENT;
import static org.springframework.web.reactive.function.server.RequestPredicates.contentType; import static org.springframework.web.reactive.function.server.RequestPredicates.contentType;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import java.net.URI; import java.net.URI;
@ -38,6 +39,7 @@ import reactor.util.retry.Retry;
import run.halo.app.core.extension.Setting; import run.halo.app.core.extension.Setting;
import run.halo.app.core.extension.Theme; import run.halo.app.core.extension.Theme;
import run.halo.app.core.extension.endpoint.CustomEndpoint; import run.halo.app.core.extension.endpoint.CustomEndpoint;
import run.halo.app.core.user.service.SettingConfigService;
import run.halo.app.extension.ConfigMap; import run.halo.app.extension.ConfigMap;
import run.halo.app.extension.ListResult; import run.halo.app.extension.ListResult;
import run.halo.app.extension.ReactiveExtensionClient; import run.halo.app.extension.ReactiveExtensionClient;
@ -75,6 +77,8 @@ public class ThemeEndpoint implements CustomEndpoint {
private final ReactiveUrlDataBufferFetcher urlDataBufferFetcher; private final ReactiveUrlDataBufferFetcher urlDataBufferFetcher;
private final SettingConfigService settingConfigService;
@Override @Override
public RouterFunction<ServerResponse> endpoint() { public RouterFunction<ServerResponse> endpoint() {
var tag = "ThemeV1alpha1Console"; var tag = "ThemeV1alpha1Console";
@ -163,8 +167,9 @@ public class ThemeEndpoint implements CustomEndpoint {
) )
.PUT("themes/{name}/config", this::updateThemeConfig, .PUT("themes/{name}/config", this::updateThemeConfig,
builder -> builder.operationId("updateThemeConfig") builder -> builder.operationId("updateThemeConfig")
.description("Update the configMap of theme setting.") .description("Update the configMap of theme setting. It is deprecated.")
.tag(tag) .tag(tag)
.deprecated(true)
.parameter(parameterBuilder() .parameter(parameterBuilder()
.name("name") .name("name")
.in(ParameterIn.PATH) .in(ParameterIn.PATH)
@ -178,6 +183,24 @@ public class ThemeEndpoint implements CustomEndpoint {
.response(responseBuilder() .response(responseBuilder()
.implementation(ConfigMap.class)) .implementation(ConfigMap.class))
) )
.PUT("themes/{name}/json-config", this::updateThemeJsonConfig,
builder -> builder.operationId("updateThemeJsonConfig")
.description("Update the configMap of theme setting.")
.tag(tag)
.parameter(parameterBuilder()
.name("name")
.in(ParameterIn.PATH)
.required(true)
.implementation(String.class)
)
.requestBody(requestBodyBuilder()
.required(true)
.content(contentBuilder().mediaType(MediaType.APPLICATION_JSON_VALUE)
.schema(schemaBuilder().implementation(ObjectNode.class))))
.response(responseBuilder()
.responseCode(String.valueOf(NO_CONTENT.value()))
.implementation(Void.class))
)
.PUT("themes/{name}/activation", this::activateTheme, .PUT("themes/{name}/activation", this::activateTheme,
builder -> builder.operationId("activateTheme") builder -> builder.operationId("activateTheme")
.description("Activate a theme by name.") .description("Activate a theme by name.")
@ -237,8 +260,10 @@ public class ThemeEndpoint implements CustomEndpoint {
) )
.GET("themes/{name}/config", this::fetchThemeConfig, .GET("themes/{name}/config", this::fetchThemeConfig,
builder -> builder.operationId("fetchThemeConfig") builder -> builder.operationId("fetchThemeConfig")
.description("Fetch configMap of theme by configured configMapName.") .description(
"Fetch configMap of theme by configured configMapName. It is deprecated.")
.tag(tag) .tag(tag)
.deprecated(true)
.parameter(parameterBuilder() .parameter(parameterBuilder()
.name("name") .name("name")
.in(ParameterIn.PATH) .in(ParameterIn.PATH)
@ -248,9 +273,52 @@ public class ThemeEndpoint implements CustomEndpoint {
.response(responseBuilder() .response(responseBuilder()
.implementation(ConfigMap.class)) .implementation(ConfigMap.class))
) )
.GET("themes/{name}/json-config", this::fetchThemeJsonConfig,
builder -> builder.operationId("fetchThemeJsonConfig")
.description(
"Fetch converted json config of theme by configured configMapName.")
.tag(tag)
.parameter(parameterBuilder()
.name("name")
.in(ParameterIn.PATH)
.required(true)
.implementation(String.class)
)
.response(responseBuilder()
.implementation(ObjectNode.class))
)
.build(); .build();
} }
private Mono<ServerResponse> fetchThemeJsonConfig(ServerRequest request) {
return themeNameInPathVariableOrActivated(request)
.flatMap(themeName -> client.fetch(Theme.class, themeName))
.mapNotNull(theme -> theme.getSpec().getConfigMapName())
.flatMap(settingConfigService::fetchConfig)
.flatMap(json -> ServerResponse.ok().bodyValue(json));
}
private Mono<ServerResponse> updateThemeJsonConfig(ServerRequest request) {
final var themeName = request.pathVariable("name");
return client.fetch(Theme.class, themeName)
.doOnNext(theme -> {
String configMapName = theme.getSpec().getConfigMapName();
if (StringUtils.isBlank(configMapName)) {
throw new ServerWebInputException(
"Unable to complete the request because the theme configMapName is blank.");
}
})
.flatMap(theme -> {
final var configMapName = theme.getSpec().getConfigMapName();
return request.bodyToMono(ObjectNode.class)
.switchIfEmpty(
Mono.error(new ServerWebInputException("Required request body is missing")))
.flatMap(configJsonData ->
settingConfigService.upsertConfig(configMapName, configJsonData));
})
.then(ServerResponse.noContent().build());
}
private Mono<ServerResponse> invalidateCache(ServerRequest request) { private Mono<ServerResponse> invalidateCache(ServerRequest request) {
final var name = request.pathVariable("name"); final var name = request.pathVariable("name");
return client.get(Theme.class, name) return client.get(Theme.class, name)
@ -308,6 +376,7 @@ public class ThemeEndpoint implements CustomEndpoint {
.flatMap(activatedTheme -> ServerResponse.ok().bodyValue(activatedTheme)); .flatMap(activatedTheme -> ServerResponse.ok().bodyValue(activatedTheme));
} }
@Deprecated(since = "2.20.0", forRemoval = true)
private Mono<ServerResponse> updateThemeConfig(ServerRequest request) { private Mono<ServerResponse> updateThemeConfig(ServerRequest request) {
final var themeName = request.pathVariable("name"); final var themeName = request.pathVariable("name");
return client.fetch(Theme.class, themeName) return client.fetch(Theme.class, themeName)
@ -345,6 +414,7 @@ public class ThemeEndpoint implements CustomEndpoint {
.flatMap(configMap -> ServerResponse.ok().bodyValue(configMap)); .flatMap(configMap -> ServerResponse.ok().bodyValue(configMap));
} }
@Deprecated(since = "2.20.0", forRemoval = true)
private Mono<ServerResponse> fetchThemeConfig(ServerRequest request) { private Mono<ServerResponse> fetchThemeConfig(ServerRequest request) {
return themeNameInPathVariableOrActivated(request) return themeNameInPathVariableOrActivated(request)
.flatMap(themeName -> client.fetch(Theme.class, themeName)) .flatMap(themeName -> client.fetch(Theme.class, themeName))

View File

@ -16,8 +16,8 @@ rules:
resources: [ "plugins" ] resources: [ "plugins" ]
verbs: [ "create", "patch", "update", "delete", "deletecollection" ] verbs: [ "create", "patch", "update", "delete", "deletecollection" ]
- apiGroups: [ "api.console.halo.run" ] - apiGroups: [ "api.console.halo.run" ]
resources: [ "plugins/upgrade", "plugins/resetconfig", "plugins/config", "plugins/reload", resources: [ "plugins/upgrade", "plugins/resetconfig", "plugins/config", "plugins/json-config",
"plugins/install-from-uri", "plugins/upgrade-from-uri", "plugins/plugin-state" ] "plugins/reload", "plugins/install-from-uri", "plugins/upgrade-from-uri", "plugins/plugin-state" ]
verbs: [ "*" ] verbs: [ "*" ]
- apiGroups: [ "api.console.halo.run" ] - apiGroups: [ "api.console.halo.run" ]
resources: [ "plugin-presets" ] resources: [ "plugin-presets" ]
@ -41,5 +41,5 @@ rules:
resources: [ "plugins" ] resources: [ "plugins" ]
verbs: [ "get", "list" ] verbs: [ "get", "list" ]
- apiGroups: [ "api.console.halo.run" ] - apiGroups: [ "api.console.halo.run" ]
resources: [ "plugins", "plugins/setting", "plugins/config" ] resources: [ "plugins", "plugins/setting", "plugins/config", "plugins/json-config" ]
verbs: [ "get", "list" ] verbs: [ "get", "list" ]

View File

@ -15,8 +15,8 @@ rules:
resources: [ "themes" ] resources: [ "themes" ]
verbs: [ "*" ] verbs: [ "*" ]
- apiGroups: [ "api.console.halo.run" ] - apiGroups: [ "api.console.halo.run" ]
resources: [ "themes", "themes/reload", "themes/resetconfig", "themes/config", "themes/activation", resources: [ "themes", "themes/reload", "themes/resetconfig", "themes/config", "themes/json-config",
"themes/install-from-uri", "themes/upgrade-from-uri", "themes/invalidate-cache" ] "themes/activation", "themes/install-from-uri", "themes/upgrade-from-uri", "themes/invalidate-cache" ]
verbs: [ "*" ] verbs: [ "*" ]
- nonResourceURLs: [ "/apis/api.console.halo.run/themes/install" ] - nonResourceURLs: [ "/apis/api.console.halo.run/themes/install" ]
verbs: [ "create" ] verbs: [ "create" ]
@ -37,6 +37,6 @@ rules:
resources: [ "themes" ] resources: [ "themes" ]
verbs: [ "get", "list" ] verbs: [ "get", "list" ]
- apiGroups: [ "api.console.halo.run" ] - apiGroups: [ "api.console.halo.run" ]
resources: [ "themes", "themes/activation", "themes/setting", "themes/config" ] resources: [ "themes", "themes/activation", "themes/setting", "themes/config", "themes/json-config" ]
verbs: [ "get", "list" ] verbs: [ "get", "list" ]

View File

@ -22,6 +22,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.Instant; import java.time.Instant;
import java.util.List; import java.util.List;
import java.util.Map;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
@ -44,6 +45,7 @@ import org.springframework.web.server.ServerWebInputException;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import run.halo.app.core.extension.Plugin; import run.halo.app.core.extension.Plugin;
import run.halo.app.core.extension.Setting; import run.halo.app.core.extension.Setting;
import run.halo.app.core.user.service.SettingConfigService;
import run.halo.app.extension.ConfigMap; import run.halo.app.extension.ConfigMap;
import run.halo.app.extension.ListOptions; import run.halo.app.extension.ListOptions;
import run.halo.app.extension.ListResult; import run.halo.app.extension.ListResult;
@ -67,6 +69,9 @@ class PluginEndpointTest {
@Mock @Mock
PluginService pluginService; PluginService pluginService;
@Mock
SettingConfigService settingConfigService;
@Spy @Spy
WebProperties webProperties = new WebProperties(); WebProperties webProperties = new WebProperties();
@ -278,6 +283,22 @@ class PluginEndpointTest {
.exchange() .exchange()
.expectStatus().isOk(); .expectStatus().isOk();
} }
@Test
void updateJsonConfigTest() {
Plugin plugin = createPlugin("fake-plugin");
plugin.getSpec().setConfigMapName("fake-config-map");
when(client.fetch(eq(Plugin.class), eq("fake-plugin"))).thenReturn(Mono.just(plugin));
when(settingConfigService.upsertConfig(eq("fake-config-map"), any()))
.thenReturn(Mono.empty());
webClient.put()
.uri("/plugins/fake-plugin/json-config")
.body(Mono.just(Map.of()), Map.class)
.exchange()
.expectStatus().is2xxSuccessful();
}
} }
@Nested @Nested
@ -325,6 +346,23 @@ class PluginEndpointTest {
verify(client).fetch(eq(ConfigMap.class), eq("fake-config")); verify(client).fetch(eq(ConfigMap.class), eq("fake-config"));
verify(client).fetch(eq(Plugin.class), eq("fake")); verify(client).fetch(eq(Plugin.class), eq("fake"));
} }
@Test
void fetchJsonConfig() {
Plugin plugin = createPlugin("fake");
plugin.getSpec().setConfigMapName("fake-config");
when(settingConfigService.fetchConfig(eq("fake-config")))
.thenReturn(Mono.empty());
when(client.fetch(eq(Plugin.class), eq("fake"))).thenReturn(Mono.just(plugin));
webClient.get()
.uri("/plugins/fake/json-config")
.exchange()
.expectStatus().isOk();
verify(settingConfigService).fetchConfig(eq("fake-config"));
verify(client).fetch(eq(Plugin.class), eq("fake"));
}
} }
Plugin createPlugin(String name) { Plugin createPlugin(String name) {

View File

@ -14,6 +14,7 @@ import java.io.IOException;
import java.net.URI; import java.net.URI;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.util.Map;
import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Nested; import org.junit.jupiter.api.Nested;
@ -33,6 +34,7 @@ import org.springframework.web.server.ServerWebInputException;
import reactor.core.publisher.Mono; import reactor.core.publisher.Mono;
import run.halo.app.core.extension.Setting; import run.halo.app.core.extension.Setting;
import run.halo.app.core.extension.Theme; import run.halo.app.core.extension.Theme;
import run.halo.app.core.user.service.SettingConfigService;
import run.halo.app.extension.ConfigMap; import run.halo.app.extension.ConfigMap;
import run.halo.app.extension.Metadata; import run.halo.app.extension.Metadata;
import run.halo.app.extension.ReactiveExtensionClient; import run.halo.app.extension.ReactiveExtensionClient;
@ -70,6 +72,9 @@ class ThemeEndpointTest {
@Mock @Mock
private ReactiveUrlDataBufferFetcher urlDataBufferFetcher; private ReactiveUrlDataBufferFetcher urlDataBufferFetcher;
@Mock
private SettingConfigService settingConfigService;
@InjectMocks @InjectMocks
ThemeEndpoint themeEndpoint; ThemeEndpoint themeEndpoint;
@ -299,8 +304,25 @@ class ThemeEndpointTest {
.exchange() .exchange()
.expectStatus().isOk(); .expectStatus().isOk();
} }
}
@Test
void updateJsonConfigTest() {
Theme theme = new Theme();
theme.setMetadata(new Metadata());
theme.setSpec(new Theme.ThemeSpec());
theme.getSpec().setConfigMapName("fake-config-map");
when(client.fetch(eq(Theme.class), eq("fake-theme"))).thenReturn(Mono.just(theme));
when(settingConfigService.upsertConfig(eq("fake-config-map"), any()))
.thenReturn(Mono.empty());
webTestClient.put()
.uri("/themes/fake-theme/json-config")
.body(Mono.just(Map.of()), Map.class)
.exchange()
.expectStatus().is2xxSuccessful();
}
}
@Test @Test
void fetchActivatedTheme() { void fetchActivatedTheme() {
@ -361,4 +383,24 @@ class ThemeEndpointTest {
verify(client).fetch(eq(ConfigMap.class), eq("fake-config")); verify(client).fetch(eq(ConfigMap.class), eq("fake-config"));
verify(client).fetch(eq(Theme.class), eq("fake")); verify(client).fetch(eq(Theme.class), eq("fake"));
} }
@Test
void fetchThemeJsonConfigTest() {
Theme theme = new Theme();
theme.setMetadata(new Metadata());
theme.getMetadata().setName("fake");
theme.setSpec(new Theme.ThemeSpec());
theme.getSpec().setConfigMapName("fake-config");
when(settingConfigService.fetchConfig(eq("fake-config"))).thenReturn(Mono.empty());
when(client.fetch(eq(Theme.class), eq("fake"))).thenReturn(Mono.just(theme));
webTestClient.get()
.uri("/themes/fake/json-config")
.exchange()
.expectStatus().isOk();
verify(settingConfigService).fetchConfig(eq("fake-config"));
verify(client).fetch(eq(Theme.class), eq("fake"));
}
} }

View File

@ -1,19 +1,13 @@
<script lang="ts" setup> <script lang="ts" setup>
// core libs
import { computed, inject, ref, toRaw } from "vue";
// components
import { Toast, VButton } from "@halo-dev/components";
// types
import type { ConfigMap, Setting, Theme } from "@halo-dev/api-client";
import type { Ref } from "vue";
// hooks
import StickyBlock from "@/components/sticky-block/StickyBlock.vue"; import StickyBlock from "@/components/sticky-block/StickyBlock.vue";
import { useSettingFormConvert } from "@console/composables/use-setting-form"; import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
import type { Setting, Theme } from "@halo-dev/api-client";
import { consoleApiClient } from "@halo-dev/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Toast, VButton } from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { cloneDeep, set } from "lodash-es";
import type { Ref } from "vue";
import { computed, inject, ref, toRaw } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
const { t } = useI18n(); const { t } = useI18n();
@ -26,10 +20,10 @@ const setting = inject<Ref<Setting | undefined>>("setting", ref());
const saving = ref(false); const saving = ref(false);
const { data: configMap, suspense } = useQuery<ConfigMap>({ const { data: configMapData, suspense } = useQuery({
queryKey: ["theme-configMap", selectedTheme], queryKey: ["core:theme:configMap:data", selectedTheme],
queryFn: async () => { queryFn: async () => {
const { data } = await consoleApiClient.theme.theme.fetchThemeConfig({ const { data } = await consoleApiClient.theme.theme.fetchThemeJsonConfig({
name: selectedTheme?.value?.metadata.name as string, name: selectedTheme?.value?.metadata.name as string,
}); });
return data; return data;
@ -39,30 +33,37 @@ const { data: configMap, suspense } = useQuery<ConfigMap>({
}), }),
}); });
const { configMapFormData, formSchema, convertToSave } = useSettingFormConvert( const currentConfigMapGroupData = computed(() => {
setting, return configMapData.value?.[group.value];
configMap, });
group
);
const handleSaveConfigMap = async () => { const formSchema = computed(() => {
if (!setting.value) {
return;
}
const { forms } = setting.value.spec;
return forms.find((item) => item.group === group?.value)?.formSchema as (
| FormKitSchemaCondition
| FormKitSchemaNode
)[];
});
const handleSaveConfigMap = async (data: object) => {
saving.value = true; saving.value = true;
const configMapToUpdate = convertToSave(); if (!selectedTheme?.value) {
if (!configMapToUpdate || !selectedTheme?.value) {
saving.value = false; saving.value = false;
return; return;
} }
await consoleApiClient.theme.theme.updateThemeConfig({ await consoleApiClient.theme.theme.updateThemeJsonConfig({
name: selectedTheme?.value?.metadata.name, name: selectedTheme?.value?.metadata.name,
configMap: configMapToUpdate, body: set(cloneDeep(configMapData.value) || {}, group.value, data),
}); });
Toast.success(t("core.common.toast.save_success")); Toast.success(t("core.common.toast.save_success"));
queryClient.invalidateQueries({ queryKey: ["theme-configMap"] }); queryClient.invalidateQueries({ queryKey: ["core:theme:configMap:data"] });
saving.value = false; saving.value = false;
}; };
@ -73,18 +74,16 @@ await suspense();
<Transition mode="out-in" name="fade"> <Transition mode="out-in" name="fade">
<div class="p-4"> <div class="p-4">
<FormKit <FormKit
v-if="group && formSchema && configMapFormData?.[group]" v-if="group && formSchema && currentConfigMapGroupData"
:id="group" :id="group"
v-model="configMapFormData[group]" :value="currentConfigMapGroupData || {}"
:name="group" :name="group"
:actions="false"
:preserve="true"
type="form" type="form"
@submit="handleSaveConfigMap" @submit="handleSaveConfigMap"
> >
<FormKitSchema <FormKitSchema
:schema="toRaw(formSchema)" :schema="toRaw(formSchema)"
:data="configMapFormData[group]" :data="toRaw(currentConfigMapGroupData)"
/> />
</FormKit> </FormKit>
<StickyBlock <StickyBlock

View File

@ -1,10 +1,11 @@
<script lang="ts" setup> <script lang="ts" setup>
import StickyBlock from "@/components/sticky-block/StickyBlock.vue"; import StickyBlock from "@/components/sticky-block/StickyBlock.vue";
import { useSettingFormConvert } from "@console/composables/use-setting-form"; import type { FormKitSchemaCondition, FormKitSchemaNode } from "@formkit/core";
import type { ConfigMap, Plugin, Setting } from "@halo-dev/api-client"; import type { Plugin, Setting } from "@halo-dev/api-client";
import { consoleApiClient } from "@halo-dev/api-client"; import { consoleApiClient } from "@halo-dev/api-client";
import { Toast, VButton } from "@halo-dev/components"; import { Toast, VButton } from "@halo-dev/components";
import { useQuery, useQueryClient } from "@tanstack/vue-query"; import { useQuery, useQueryClient } from "@tanstack/vue-query";
import { cloneDeep, set } from "lodash-es";
import { computed, inject, ref, toRaw, type Ref } from "vue"; import { computed, inject, ref, toRaw, type Ref } from "vue";
import { useI18n } from "vue-i18n"; import { useI18n } from "vue-i18n";
@ -16,12 +17,14 @@ const plugin = inject<Ref<Plugin | undefined>>("plugin");
const setting = inject<Ref<Setting | undefined>>("setting", ref()); const setting = inject<Ref<Setting | undefined>>("setting", ref());
const saving = ref(false); const saving = ref(false);
const { data: configMap } = useQuery<ConfigMap>({ const { data: configMapData } = useQuery({
queryKey: ["plugin-configMap", plugin], queryKey: ["core:plugin:configMap:data", plugin],
queryFn: async () => { queryFn: async () => {
const { data } = await consoleApiClient.plugin.plugin.fetchPluginConfig({ const { data } = await consoleApiClient.plugin.plugin.fetchPluginJsonConfig(
name: plugin?.value?.metadata.name as string, {
}); name: plugin?.value?.metadata.name as string,
}
);
return data; return data;
}, },
enabled: computed(() => { enabled: computed(() => {
@ -29,28 +32,37 @@ const { data: configMap } = useQuery<ConfigMap>({
}), }),
}); });
const { configMapFormData, formSchema, convertToSave } = useSettingFormConvert( const currentConfigMapGroupData = computed(() => {
setting, return configMapData.value?.[group.value];
configMap, });
group
);
const handleSaveConfigMap = async () => { const formSchema = computed(() => {
if (!setting.value) {
return;
}
const { forms } = setting.value.spec;
return forms.find((item) => item.group === group?.value)?.formSchema as (
| FormKitSchemaCondition
| FormKitSchemaNode
)[];
});
const handleSaveConfigMap = async (data: object) => {
saving.value = true; saving.value = true;
const configMapToUpdate = convertToSave();
if (!configMapToUpdate || !plugin?.value) { if (!plugin?.value) {
saving.value = false; saving.value = false;
return; return;
} }
await consoleApiClient.plugin.plugin.updatePluginConfig({ await consoleApiClient.plugin.plugin.updatePluginJsonConfig({
name: plugin.value.metadata.name, name: plugin.value.metadata.name,
configMap: configMapToUpdate, body: set(cloneDeep(configMapData.value) || {}, group.value, data),
}); });
Toast.success(t("core.common.toast.save_success")); Toast.success(t("core.common.toast.save_success"));
queryClient.invalidateQueries({ queryKey: ["plugin-configMap"] }); queryClient.invalidateQueries({ queryKey: ["core:plugin:configMap:data"] });
saving.value = false; saving.value = false;
}; };
@ -60,18 +72,16 @@ const handleSaveConfigMap = async () => {
<div class="rounded-b-base bg-white p-4"> <div class="rounded-b-base bg-white p-4">
<div> <div>
<FormKit <FormKit
v-if="group && formSchema && configMapFormData?.[group]" v-if="group && formSchema && currentConfigMapGroupData"
:id="group" :id="group"
v-model="configMapFormData[group]" :value="currentConfigMapGroupData"
:name="group" :name="group"
:actions="false"
:preserve="true"
type="form" type="form"
@submit="handleSaveConfigMap" @submit="handleSaveConfigMap"
> >
<FormKitSchema <FormKitSchema
:schema="toRaw(formSchema)" :schema="toRaw(formSchema)"
:data="configMapFormData[group]" :data="toRaw(currentConfigMapGroupData)"
/> />
</FormKit> </FormKit>
</div> </div>

View File

@ -163,7 +163,7 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
}; };
}, },
/** /**
* Fetch configMap of plugin by configured configMapName. * Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
* @param {string} name * @param {string} name
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -194,6 +194,47 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Fetch converted json config of plugin by configured configMapName.
* @param {string} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchPluginJsonConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('fetchPluginJsonConfig', 'name', name)
const localVarPath = `/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config`
.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: '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); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@ -535,10 +576,11 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
}; };
}, },
/** /**
* Update the configMap of plugin setting. * Update the configMap of plugin setting, it is deprecated since 2.20.0
* @param {string} name * @param {string} name
* @param {ConfigMap} configMap * @param {ConfigMap} configMap
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
updatePluginConfig: async (name: string, configMap: ConfigMap, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { updatePluginConfig: async (name: string, configMap: ConfigMap, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
@ -581,6 +623,53 @@ export const PluginV1alpha1ConsoleApiAxiosParamCreator = function (configuration
options: localVarRequestOptions, options: localVarRequestOptions,
}; };
}, },
/**
* Update the config of plugin setting.
* @param {string} name
* @param {object} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePluginJsonConfig: async (name: string, body: object, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('updatePluginJsonConfig', 'name', name)
// verify required parameter 'body' is not null or undefined
assertParamExists('updatePluginJsonConfig', 'body', body)
const localVarPath = `/apis/api.console.halo.run/v1alpha1/plugins/{name}/json-config`
.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: 'PUT', ...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(body, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/** /**
* Upgrade a plugin by uploading a Jar file * Upgrade a plugin by uploading a Jar file
* @param {string} name * @param {string} name
@ -734,7 +823,7 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/** /**
* Fetch configMap of plugin by configured configMapName. * Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
* @param {string} name * @param {string} name
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -745,6 +834,18 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.fetchPluginConfig']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.fetchPluginConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/**
* Fetch converted json config of plugin by configured configMapName.
* @param {string} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async fetchPluginJsonConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchPluginJsonConfig(name, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.fetchPluginJsonConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/** /**
* Fetch setting of plugin. * Fetch setting of plugin.
* @param {string} name * @param {string} name
@ -837,10 +938,11 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/** /**
* Update the configMap of plugin setting. * Update the configMap of plugin setting, it is deprecated since 2.20.0
* @param {string} name * @param {string} name
* @param {ConfigMap} configMap * @param {ConfigMap} configMap
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async updatePluginConfig(name: string, configMap: ConfigMap, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> { async updatePluginConfig(name: string, configMap: ConfigMap, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> {
@ -849,6 +951,19 @@ export const PluginV1alpha1ConsoleApiFp = function(configuration?: Configuration
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.updatePluginConfig']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.updatePluginConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/**
* Update the config of plugin setting.
* @param {string} name
* @param {object} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updatePluginJsonConfig(name: string, body: object, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updatePluginJsonConfig(name, body, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['PluginV1alpha1ConsoleApi.updatePluginJsonConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/** /**
* Upgrade a plugin by uploading a Jar file * Upgrade a plugin by uploading a Jar file
* @param {string} name * @param {string} name
@ -913,7 +1028,7 @@ export const PluginV1alpha1ConsoleApiFactory = function (configuration?: Configu
return localVarFp.fetchJsBundle(options).then((request) => request(axios, basePath)); return localVarFp.fetchJsBundle(options).then((request) => request(axios, basePath));
}, },
/** /**
* Fetch configMap of plugin by configured configMapName. * Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
* @param {PluginV1alpha1ConsoleApiFetchPluginConfigRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiFetchPluginConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -921,6 +1036,15 @@ export const PluginV1alpha1ConsoleApiFactory = function (configuration?: Configu
fetchPluginConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> { fetchPluginConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
return localVarFp.fetchPluginConfig(requestParameters.name, options).then((request) => request(axios, basePath)); return localVarFp.fetchPluginConfig(requestParameters.name, options).then((request) => request(axios, basePath));
}, },
/**
* Fetch converted json config of plugin by configured configMapName.
* @param {PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchPluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<object> {
return localVarFp.fetchPluginJsonConfig(requestParameters.name, options).then((request) => request(axios, basePath));
},
/** /**
* Fetch setting of plugin. * Fetch setting of plugin.
* @param {PluginV1alpha1ConsoleApiFetchPluginSettingRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiFetchPluginSettingRequest} requestParameters Request parameters.
@ -984,14 +1108,24 @@ export const PluginV1alpha1ConsoleApiFactory = function (configuration?: Configu
return localVarFp.resetPluginConfig(requestParameters.name, options).then((request) => request(axios, basePath)); return localVarFp.resetPluginConfig(requestParameters.name, options).then((request) => request(axios, basePath));
}, },
/** /**
* Update the configMap of plugin setting. * Update the configMap of plugin setting, it is deprecated since 2.20.0
* @param {PluginV1alpha1ConsoleApiUpdatePluginConfigRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiUpdatePluginConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
updatePluginConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> { updatePluginConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
return localVarFp.updatePluginConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(axios, basePath)); return localVarFp.updatePluginConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(axios, basePath));
}, },
/**
* Update the config of plugin setting.
* @param {PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updatePluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
return localVarFp.updatePluginJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(axios, basePath));
},
/** /**
* Upgrade a plugin by uploading a Jar file * Upgrade a plugin by uploading a Jar file
* @param {PluginV1alpha1ConsoleApiUpgradePluginRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiUpgradePluginRequest} requestParameters Request parameters.
@ -1048,6 +1182,20 @@ export interface PluginV1alpha1ConsoleApiFetchPluginConfigRequest {
readonly name: string readonly name: string
} }
/**
* Request parameters for fetchPluginJsonConfig operation in PluginV1alpha1ConsoleApi.
* @export
* @interface PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest
*/
export interface PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest {
/**
*
* @type {string}
* @memberof PluginV1alpha1ConsoleApiFetchPluginJsonConfig
*/
readonly name: string
}
/** /**
* Request parameters for fetchPluginSetting operation in PluginV1alpha1ConsoleApi. * Request parameters for fetchPluginSetting operation in PluginV1alpha1ConsoleApi.
* @export * @export
@ -1209,6 +1357,27 @@ export interface PluginV1alpha1ConsoleApiUpdatePluginConfigRequest {
readonly configMap: ConfigMap readonly configMap: ConfigMap
} }
/**
* Request parameters for updatePluginJsonConfig operation in PluginV1alpha1ConsoleApi.
* @export
* @interface PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest
*/
export interface PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest {
/**
*
* @type {string}
* @memberof PluginV1alpha1ConsoleApiUpdatePluginJsonConfig
*/
readonly name: string
/**
*
* @type {object}
* @memberof PluginV1alpha1ConsoleApiUpdatePluginJsonConfig
*/
readonly body: object
}
/** /**
* Request parameters for upgradePlugin operation in PluginV1alpha1ConsoleApi. * Request parameters for upgradePlugin operation in PluginV1alpha1ConsoleApi.
* @export * @export
@ -1304,7 +1473,7 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
} }
/** /**
* Fetch configMap of plugin by configured configMapName. * Fetch configMap of plugin by configured configMapName. it is deprecated since 2.20.0
* @param {PluginV1alpha1ConsoleApiFetchPluginConfigRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiFetchPluginConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @throws {RequiredError} * @throws {RequiredError}
@ -1314,6 +1483,17 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
return PluginV1alpha1ConsoleApiFp(this.configuration).fetchPluginConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath)); return PluginV1alpha1ConsoleApiFp(this.configuration).fetchPluginConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
} }
/**
* Fetch converted json config of plugin by configured configMapName.
* @param {PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PluginV1alpha1ConsoleApi
*/
public fetchPluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiFetchPluginJsonConfigRequest, options?: RawAxiosRequestConfig) {
return PluginV1alpha1ConsoleApiFp(this.configuration).fetchPluginJsonConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
}
/** /**
* Fetch setting of plugin. * Fetch setting of plugin.
* @param {PluginV1alpha1ConsoleApiFetchPluginSettingRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiFetchPluginSettingRequest} requestParameters Request parameters.
@ -1391,9 +1571,10 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
} }
/** /**
* Update the configMap of plugin setting. * Update the configMap of plugin setting, it is deprecated since 2.20.0
* @param {PluginV1alpha1ConsoleApiUpdatePluginConfigRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiUpdatePluginConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
* @memberof PluginV1alpha1ConsoleApi * @memberof PluginV1alpha1ConsoleApi
*/ */
@ -1401,6 +1582,17 @@ export class PluginV1alpha1ConsoleApi extends BaseAPI {
return PluginV1alpha1ConsoleApiFp(this.configuration).updatePluginConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(this.axios, this.basePath)); return PluginV1alpha1ConsoleApiFp(this.configuration).updatePluginConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(this.axios, this.basePath));
} }
/**
* Update the config of plugin setting.
* @param {PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof PluginV1alpha1ConsoleApi
*/
public updatePluginJsonConfig(requestParameters: PluginV1alpha1ConsoleApiUpdatePluginJsonConfigRequest, options?: RawAxiosRequestConfig) {
return PluginV1alpha1ConsoleApiFp(this.configuration).updatePluginJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
/** /**
* Upgrade a plugin by uploading a Jar file * Upgrade a plugin by uploading a Jar file
* @param {PluginV1alpha1ConsoleApiUpgradePluginRequest} requestParameters Request parameters. * @param {PluginV1alpha1ConsoleApiUpgradePluginRequest} requestParameters Request parameters.

View File

@ -118,9 +118,10 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
}; };
}, },
/** /**
* Fetch configMap of theme by configured configMapName. * Fetch configMap of theme by configured configMapName. It is deprecated.
* @param {string} name * @param {string} name
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
fetchThemeConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { fetchThemeConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
@ -149,6 +150,47 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
* Fetch converted json config of theme by configured configMapName.
* @param {string} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchThemeJsonConfig: async (name: string, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('fetchThemeJsonConfig', 'name', name)
const localVarPath = `/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config`
.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: '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); setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {}; let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers}; localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
@ -465,10 +507,11 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
}; };
}, },
/** /**
* Update the configMap of theme setting. * Update the configMap of theme setting. It is deprecated.
* @param {string} name * @param {string} name
* @param {ConfigMap} configMap * @param {ConfigMap} configMap
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
updateThemeConfig: async (name: string, configMap: ConfigMap, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => { updateThemeConfig: async (name: string, configMap: ConfigMap, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
@ -511,6 +554,53 @@ export const ThemeV1alpha1ConsoleApiAxiosParamCreator = function (configuration?
options: localVarRequestOptions, options: localVarRequestOptions,
}; };
}, },
/**
* Update the configMap of theme setting.
* @param {string} name
* @param {object} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateThemeJsonConfig: async (name: string, body: object, options: RawAxiosRequestConfig = {}): Promise<RequestArgs> => {
// verify required parameter 'name' is not null or undefined
assertParamExists('updateThemeJsonConfig', 'name', name)
// verify required parameter 'body' is not null or undefined
assertParamExists('updateThemeJsonConfig', 'body', body)
const localVarPath = `/apis/api.console.halo.run/v1alpha1/themes/{name}/json-config`
.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: 'PUT', ...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(body, localVarRequestOptions, configuration)
return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/** /**
* Upgrade theme * Upgrade theme
* @param {string} name * @param {string} name
@ -644,9 +734,10 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/** /**
* Fetch configMap of theme by configured configMapName. * Fetch configMap of theme by configured configMapName. It is deprecated.
* @param {string} name * @param {string} name
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async fetchThemeConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> { async fetchThemeConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> {
@ -655,6 +746,18 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.fetchThemeConfig']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.fetchThemeConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/**
* Fetch converted json config of theme by configured configMapName.
* @param {string} name
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async fetchThemeJsonConfig(name: string, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<object>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.fetchThemeJsonConfig(name, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.fetchThemeJsonConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/** /**
* Fetch setting of theme. * Fetch setting of theme.
* @param {string} name * @param {string} name
@ -743,10 +846,11 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/** /**
* Update the configMap of theme setting. * Update the configMap of theme setting. It is deprecated.
* @param {string} name * @param {string} name
* @param {ConfigMap} configMap * @param {ConfigMap} configMap
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
async updateThemeConfig(name: string, configMap: ConfigMap, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> { async updateThemeConfig(name: string, configMap: ConfigMap, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<ConfigMap>> {
@ -755,6 +859,19 @@ export const ThemeV1alpha1ConsoleApiFp = function(configuration?: Configuration)
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.updateThemeConfig']?.[localVarOperationServerIndex]?.url; const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.updateThemeConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath); return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
}, },
/**
* Update the configMap of theme setting.
* @param {string} name
* @param {object} body
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async updateThemeJsonConfig(name: string, body: object, options?: RawAxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<void>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.updateThemeJsonConfig(name, body, options);
const localVarOperationServerIndex = configuration?.serverIndex ?? 0;
const localVarOperationServerBasePath = operationServerMap['ThemeV1alpha1ConsoleApi.updateThemeJsonConfig']?.[localVarOperationServerIndex]?.url;
return (axios, basePath) => createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration)(axios, localVarOperationServerBasePath || basePath);
},
/** /**
* Upgrade theme * Upgrade theme
* @param {string} name * @param {string} name
@ -809,14 +926,24 @@ export const ThemeV1alpha1ConsoleApiFactory = function (configuration?: Configur
return localVarFp.fetchActivatedTheme(options).then((request) => request(axios, basePath)); return localVarFp.fetchActivatedTheme(options).then((request) => request(axios, basePath));
}, },
/** /**
* Fetch configMap of theme by configured configMapName. * Fetch configMap of theme by configured configMapName. It is deprecated.
* @param {ThemeV1alpha1ConsoleApiFetchThemeConfigRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiFetchThemeConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
fetchThemeConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> { fetchThemeConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
return localVarFp.fetchThemeConfig(requestParameters.name, options).then((request) => request(axios, basePath)); return localVarFp.fetchThemeConfig(requestParameters.name, options).then((request) => request(axios, basePath));
}, },
/**
* Fetch converted json config of theme by configured configMapName.
* @param {ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
fetchThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<object> {
return localVarFp.fetchThemeJsonConfig(requestParameters.name, options).then((request) => request(axios, basePath));
},
/** /**
* Fetch setting of theme. * Fetch setting of theme.
* @param {ThemeV1alpha1ConsoleApiFetchThemeSettingRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiFetchThemeSettingRequest} requestParameters Request parameters.
@ -880,14 +1007,24 @@ export const ThemeV1alpha1ConsoleApiFactory = function (configuration?: Configur
return localVarFp.resetThemeConfig(requestParameters.name, options).then((request) => request(axios, basePath)); return localVarFp.resetThemeConfig(requestParameters.name, options).then((request) => request(axios, basePath));
}, },
/** /**
* Update the configMap of theme setting. * Update the configMap of theme setting. It is deprecated.
* @param {ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
*/ */
updateThemeConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> { updateThemeConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<ConfigMap> {
return localVarFp.updateThemeConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(axios, basePath)); return localVarFp.updateThemeConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(axios, basePath));
}, },
/**
* Update the configMap of theme setting.
* @param {ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
updateThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest, options?: RawAxiosRequestConfig): AxiosPromise<void> {
return localVarFp.updateThemeJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(axios, basePath));
},
/** /**
* Upgrade theme * Upgrade theme
* @param {ThemeV1alpha1ConsoleApiUpgradeThemeRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiUpgradeThemeRequest} requestParameters Request parameters.
@ -937,6 +1074,20 @@ export interface ThemeV1alpha1ConsoleApiFetchThemeConfigRequest {
readonly name: string readonly name: string
} }
/**
* Request parameters for fetchThemeJsonConfig operation in ThemeV1alpha1ConsoleApi.
* @export
* @interface ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest
*/
export interface ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest {
/**
*
* @type {string}
* @memberof ThemeV1alpha1ConsoleApiFetchThemeJsonConfig
*/
readonly name: string
}
/** /**
* Request parameters for fetchThemeSetting operation in ThemeV1alpha1ConsoleApi. * Request parameters for fetchThemeSetting operation in ThemeV1alpha1ConsoleApi.
* @export * @export
@ -1070,6 +1221,27 @@ export interface ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest {
readonly configMap: ConfigMap readonly configMap: ConfigMap
} }
/**
* Request parameters for updateThemeJsonConfig operation in ThemeV1alpha1ConsoleApi.
* @export
* @interface ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest
*/
export interface ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest {
/**
*
* @type {string}
* @memberof ThemeV1alpha1ConsoleApiUpdateThemeJsonConfig
*/
readonly name: string
/**
*
* @type {object}
* @memberof ThemeV1alpha1ConsoleApiUpdateThemeJsonConfig
*/
readonly body: object
}
/** /**
* Request parameters for upgradeTheme operation in ThemeV1alpha1ConsoleApi. * Request parameters for upgradeTheme operation in ThemeV1alpha1ConsoleApi.
* @export * @export
@ -1141,9 +1313,10 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
} }
/** /**
* Fetch configMap of theme by configured configMapName. * Fetch configMap of theme by configured configMapName. It is deprecated.
* @param {ThemeV1alpha1ConsoleApiFetchThemeConfigRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiFetchThemeConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
* @memberof ThemeV1alpha1ConsoleApi * @memberof ThemeV1alpha1ConsoleApi
*/ */
@ -1151,6 +1324,17 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
return ThemeV1alpha1ConsoleApiFp(this.configuration).fetchThemeConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath)); return ThemeV1alpha1ConsoleApiFp(this.configuration).fetchThemeConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
} }
/**
* Fetch converted json config of theme by configured configMapName.
* @param {ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ThemeV1alpha1ConsoleApi
*/
public fetchThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiFetchThemeJsonConfigRequest, options?: RawAxiosRequestConfig) {
return ThemeV1alpha1ConsoleApiFp(this.configuration).fetchThemeJsonConfig(requestParameters.name, options).then((request) => request(this.axios, this.basePath));
}
/** /**
* Fetch setting of theme. * Fetch setting of theme.
* @param {ThemeV1alpha1ConsoleApiFetchThemeSettingRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiFetchThemeSettingRequest} requestParameters Request parameters.
@ -1228,9 +1412,10 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
} }
/** /**
* Update the configMap of theme setting. * Update the configMap of theme setting. It is deprecated.
* @param {ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiUpdateThemeConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option. * @param {*} [options] Override http request option.
* @deprecated
* @throws {RequiredError} * @throws {RequiredError}
* @memberof ThemeV1alpha1ConsoleApi * @memberof ThemeV1alpha1ConsoleApi
*/ */
@ -1238,6 +1423,17 @@ export class ThemeV1alpha1ConsoleApi extends BaseAPI {
return ThemeV1alpha1ConsoleApiFp(this.configuration).updateThemeConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(this.axios, this.basePath)); return ThemeV1alpha1ConsoleApiFp(this.configuration).updateThemeConfig(requestParameters.name, requestParameters.configMap, options).then((request) => request(this.axios, this.basePath));
} }
/**
* Update the configMap of theme setting.
* @param {ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest} requestParameters Request parameters.
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof ThemeV1alpha1ConsoleApi
*/
public updateThemeJsonConfig(requestParameters: ThemeV1alpha1ConsoleApiUpdateThemeJsonConfigRequest, options?: RawAxiosRequestConfig) {
return ThemeV1alpha1ConsoleApiFp(this.configuration).updateThemeJsonConfig(requestParameters.name, requestParameters.body, options).then((request) => request(this.axios, this.basePath));
}
/** /**
* Upgrade theme * Upgrade theme
* @param {ThemeV1alpha1ConsoleApiUpgradeThemeRequest} requestParameters Request parameters. * @param {ThemeV1alpha1ConsoleApiUpgradeThemeRequest} requestParameters Request parameters.