All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.eclipse.xpanse.api.controllers.ServiceConfigurationApi Maven / Gradle / Ivy
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: Huawei Inc.
*
*/
package org.eclipse.xpanse.api.controllers;
import static org.eclipse.xpanse.modules.security.common.RoleConstants.ROLE_ADMIN;
import static org.eclipse.xpanse.modules.security.common.RoleConstants.ROLE_USER;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import java.util.List;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.xpanse.api.config.AuditApiRequest;
import org.eclipse.xpanse.modules.deployment.ServiceConfigurationManager;
import org.eclipse.xpanse.modules.models.service.order.ServiceOrder;
import org.eclipse.xpanse.modules.models.serviceconfiguration.ServiceConfigurationChangeOrderDetails;
import org.eclipse.xpanse.modules.models.serviceconfiguration.ServiceConfigurationDetails;
import org.eclipse.xpanse.modules.models.serviceconfiguration.ServiceConfigurationUpdate;
import org.eclipse.xpanse.modules.models.serviceconfiguration.enums.ServiceConfigurationStatus;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
/**
* REST interface methods for service configuration.
*/
@Slf4j
@RestController
@RequestMapping("/xpanse")
@CrossOrigin
@Secured({ROLE_ADMIN, ROLE_USER})
@ConditionalOnProperty(name = "enable.agent.api.only", havingValue = "false", matchIfMissing = true)
public class ServiceConfigurationApi {
@Resource
private ServiceConfigurationManager serviceConfigurationManager;
/**
* Query the service's current configuration by id of the deployed service.
*
* @param serviceId id of the deployed service.
* @return ServiceConfigurationEntity.
*/
@Tag(name = "ServiceConfiguration",
description = "APIs for managing service's configuration.")
@GetMapping(value = "/service/current/config/{serviceId}",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Operation(description = "Query the service's current configuration by"
+ " id of the deployed service.")
@AuditApiRequest(methodName = "getCspFromServiceId")
public ServiceConfigurationDetails getCurrentConfigurationOfService(
@Parameter(name = "serviceId", description = "The id of the deployed service")
@PathVariable("serviceId") String serviceId) {
return serviceConfigurationManager.getCurrentConfigurationOfService(serviceId);
}
/**
* Update the service's configuration to the registered service template.
*
* @param serviceId id of the deployed service
* @param serviceConfigurationUpdate serviceConfigurationUpdate.
* @return serviceOrder.
*/
@Tag(name = "ServiceConfiguration",
description = "APIs for managing service's configuration.")
@PutMapping(value = "/services/config/{serviceId}",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Operation(description = "Update the service's configuration to the registered service "
+ "template.")
@AuditApiRequest(methodName = "getCspFromServiceId")
public ServiceOrder changeServiceConfiguration(
@Parameter(name = "serviceId", description = "The id of the deployed service")
@PathVariable("serviceId") String serviceId,
@Valid @RequestBody ServiceConfigurationUpdate serviceConfigurationUpdate) {
return serviceConfigurationManager.changeServiceConfiguration(serviceId,
serviceConfigurationUpdate);
}
/**
* List all service configuration update request.
*
*/
@Tag(name = "ServiceConfiguration",
description = "APIs for managing service's configuration.")
@GetMapping(value = "/services/config/requests",
produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@Operation(description = "List service's configuration.")
@AuditApiRequest(methodName = "getCspFromServiceId")
public List
getAllServiceConfigurationChangeDetails(
@Parameter(name = "serviceId", description = "Id of the deployed service")
@RequestParam(name = "serviceId") String serviceId,
@Parameter(name = "orderId", description = "id of the service order")
@RequestParam(name = "orderId", required = false) String orderId,
@Parameter(name = "resourceName", description = "name of the service resource")
@RequestParam(name = "resourceName", required = false) String resourceName,
@Parameter(name = "configManager",
description = "Manager of the service configuration parameter.")
@RequestParam(name = "configManager", required = false) String configManager,
@Parameter(name = "status", description = "Status of the service configuration")
@RequestParam(name = "status", required = false) ServiceConfigurationStatus status) {
return serviceConfigurationManager.getAllServiceConfigurationChangeDetails(
orderId, serviceId, resourceName, configManager, status);
}
}