You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by yk...@apache.org on 2021/02/15 11:56:21 UTC

[incubator-datalab] branch DATALAB-2228 created (now 81ef75a)

This is an automated email from the ASF dual-hosted git repository.

ykinash pushed a change to branch DATALAB-2228
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git.


      at 81ef75a  [DATALAB-2228] - added possibility of change properties on external endpoint

This branch includes the following new commits:

     new b1dbf99  [DATALAB-1716] - showed absent values in "Billing report"
     new 749bc98  Merge branch 'develop' of https://github.com/apache/incubator-datalab into develop
     new 6748a70  [DATALAB-2228] - added possibility of change properties on external endpoint
     new 81ef75a  [DATALAB-2228] - added possibility of change properties on external endpoint

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org


[incubator-datalab] 02/04: Merge branch 'develop' of https://github.com/apache/incubator-datalab into develop

Posted by yk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ykinash pushed a commit to branch DATALAB-2228
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 749bc98b22bc567cf6f2766a7691752f96fa31e8
Merge: b1dbf99 cb0bb49
Author: KinashYurii <ur...@gmail.com>
AuthorDate: Thu Feb 11 16:19:18 2021 +0200

    Merge branch 'develop' of https://github.com/apache/incubator-datalab into develop

 .../src/dataengine/scripts/configure_dataengine.py |  2 +-
 .../src/general/conf/datalab.ini                   |  2 ++
 .../src/jupyter/scripts/configure_jupyter_node.py  |  2 +-
 .../scripts/configure_jupyterlab_node.py           |  2 +-
 .../src/rstudio/scripts/configure_rstudio_node.py  |  2 +-
 .../scripts/configure_tensor-rstudio_node.py       |  2 +-
 .../zeppelin/scripts/configure_zeppelin_node.py    |  2 +-
 .../configuration/configuration.component.html     | 39 ++++++++++++----------
 .../configuration/configuration.component.ts       | 27 +++++++--------
 .../app/core/services/configutration.service.ts    | 13 ++++++--
 .../reporting-grid/reporting-grid.component.html   | 11 +++++-
 .../reporting-grid/reporting-grid.component.scss   | 13 ++++----
 .../bucket-browser/bucket-browser.component.ts     |  1 +
 .../bucket-confirmation-dialog.component.scss      |  4 +--
 .../resources-grid/resources-grid.component.scss   |  1 +
 .../multi-select-dropdown.component.html           |  2 +-
 .../src/main/resources/webapp/src/styles.scss      |  4 +++
 17 files changed, 80 insertions(+), 49 deletions(-)


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org


[incubator-datalab] 03/04: [DATALAB-2228] - added possibility of change properties on external endpoint

Posted by yk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ykinash pushed a commit to branch DATALAB-2228
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 6748a709a90763ef044579c33396e93d5de07cb5
Author: KinashYurii <ur...@gmail.com>
AuthorDate: Fri Feb 12 14:06:08 2021 +0200

    [DATALAB-2228] - added possibility of change properties on external endpoint
---
 .../resources/admin/ChangePropertiesResource.java  | 119 +++++++++++++++++++--
 .../service/impl/DynamicChangeProperties.java      |  94 +++++++++++-----
 2 files changed, 175 insertions(+), 38 deletions(-)

diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java
index 2386b86..1c51385 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java
@@ -10,19 +10,33 @@ import lombok.NoArgsConstructor;
 import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
+import java.util.List;
+import java.util.Map;
 
-@Path("admin")
+@Path("configuration")
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
 @NoArgsConstructor
 public class ChangePropertiesResource {
 
+    private static final String SELF_SERVICE = "self-service.yml";
+    //services/self-service/self-service.yml";
+    private static final String SELF_SERVICE_PROP_PATH = "/opt/datalab/conf/self-service.yml";
+    private static final String PROVISIONING_SERVICE = "provisioning.yml";
+    //"services/provisioning-service/provisioning.yml";
+    private static final String PROVISIONING_SERVICE_PROP_PATH = "/opt/datalab/conf/provisioning.yml";
+    private static final String BILLING_SERVICE = "billing.yml";
+    //"services/billing-aws/billing.yml";
+    //"services/billing-azure/billing.yml";
+    //"services/billing-gcp/billing.yml";
+    private static final String BILLING_SERVICE_PROP_PATH = "/opt/datalab/conf/billing.yml";
+
     @GET
     @Path("/self-service")
     public Response getSelfServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getSelfServiceProperties())
+                    .ok(DynamicChangeProperties.getProperties(SELF_SERVICE_PROP_PATH, SELF_SERVICE))
                     .build();
         } else {
             return Response
@@ -36,7 +50,7 @@ public class ChangePropertiesResource {
     public Response getProvisioningServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getProvisioningServiceProperties())
+                    .ok(DynamicChangeProperties.getProperties(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE))
                     .build();
         } else {
             return Response
@@ -50,7 +64,7 @@ public class ChangePropertiesResource {
     public Response getBillingServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getBillingServiceProperties())
+                    .ok(DynamicChangeProperties.getProperties(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE))
                     .build();
         } else {
             return Response
@@ -63,7 +77,7 @@ public class ChangePropertiesResource {
     @Path("/self-service")
     public Response overwriteSelfServiceProperties(@Auth UserInfo userInfo, YmlDTO ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwriteSelfServiceProperties(ymlDTO.getYmlString());
+            DynamicChangeProperties.overwriteProperties(SELF_SERVICE_PROP_PATH, SELF_SERVICE, ymlDTO.getYmlString());
             return Response.ok().build();
         } else {
             return Response
@@ -76,7 +90,8 @@ public class ChangePropertiesResource {
     @Path("/provisioning-service")
     public Response overwriteProvisioningServiceProperties(@Auth UserInfo userInfo, YmlDTO ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwriteProvisioningServiceProperties(ymlDTO.getYmlString());
+            DynamicChangeProperties.overwriteProperties(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE,
+                    ymlDTO.getYmlString());
             return Response.ok().build();
         } else {
             return Response
@@ -89,7 +104,90 @@ public class ChangePropertiesResource {
     @Path("/billing")
     public Response overwriteBillingServiceProperties(@Auth UserInfo userInfo, YmlDTO ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwriteBillingServiceProperties(ymlDTO.getYmlString());
+            DynamicChangeProperties.overwriteProperties(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, ymlDTO.getYmlString());
+            return Response.ok().build();
+        } else {
+            return Response
+                    .status(Response.Status.FORBIDDEN)
+                    .build();
+        }
+    }
+
+    @GET
+    @Path("multiple/self-service")
+    public Response getAllSelfServiceProperties(@Auth UserInfo userInfo) {
+        if (UserRoles.isAdmin(userInfo)) {
+            return Response
+                    .ok(DynamicChangeProperties.getPropertiesWithExternal(SELF_SERVICE_PROP_PATH, SELF_SERVICE, userInfo))
+                    .build();
+        } else {
+            return Response
+                    .status(Response.Status.FORBIDDEN)
+                    .build();
+        }
+    }
+
+    @GET
+    @Path("multiple/provisioning-service")
+    public Response getAllProvisioningServiceProperties(@Auth UserInfo userInfo) {
+        if (UserRoles.isAdmin(userInfo)) {
+            return Response
+                    .ok(DynamicChangeProperties.getPropertiesWithExternal(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE, userInfo))
+                    .build();
+        } else {
+            return Response
+                    .status(Response.Status.FORBIDDEN)
+                    .build();
+        }
+    }
+
+    @GET
+    @Path("multiple/billing")
+    public Response getAllBillingServiceProperties(@Auth UserInfo userInfo) {
+        if (UserRoles.isAdmin(userInfo)) {
+            return Response
+                    .ok(DynamicChangeProperties.getPropertiesWithExternal(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, userInfo))
+                    .build();
+        } else {
+            return Response
+                    .status(Response.Status.FORBIDDEN)
+                    .build();
+        }
+    }
+
+    @POST
+    @Path("multiple/self-service")
+    public Response overwriteAllSelfServiceProperties(@Auth UserInfo userInfo, Map<String, YmlDTO> ymlDTO) {
+        if (UserRoles.isAdmin(userInfo)) {
+            DynamicChangeProperties.overwritePropertiesWithExternal(SELF_SERVICE_PROP_PATH, SELF_SERVICE, ymlDTO, userInfo);
+            return Response.ok().build();
+        } else {
+            return Response
+                    .status(Response.Status.FORBIDDEN)
+                    .build();
+        }
+    }
+
+    @POST
+    @Path("multiple/provisioning-service")
+    public Response overwriteAllProvisioningServiceProperties(@Auth UserInfo userInfo, Map<String, YmlDTO> ymlDTO) {
+        if (UserRoles.isAdmin(userInfo)) {
+            DynamicChangeProperties.overwritePropertiesWithExternal(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE,
+                    ymlDTO, userInfo);
+            return Response.ok().build();
+        } else {
+            return Response
+                    .status(Response.Status.FORBIDDEN)
+                    .build();
+        }
+    }
+
+    @POST
+    @Path("multiple/billing")
+    public Response overwriteAllBillingServiceProperties(@Auth UserInfo userInfo, Map<String, YmlDTO> ymlDTO) {
+        if (UserRoles.isAdmin(userInfo)) {
+            DynamicChangeProperties.overwritePropertiesWithExternal(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, ymlDTO,
+                    userInfo);
             return Response.ok().build();
         } else {
             return Response
@@ -103,10 +201,11 @@ public class ChangePropertiesResource {
     public Response restart(@Auth UserInfo userInfo,
                             @QueryParam("billing") boolean billing,
                             @QueryParam("provserv") boolean provserv,
-                            @QueryParam("ui") boolean ui) {
+                            @QueryParam("ui") boolean ui,
+                            @QueryParam("endpoints") List<String> endpoints) {
         if (UserRoles.isAdmin(userInfo)) {
-        DynamicChangeProperties.restart(billing, provserv, ui);
-        return Response.ok().build();
+            DynamicChangeProperties.restart(billing, provserv, ui);
+            return Response.ok().build();
         } else {
             return Response
                     .status(Response.Status.FORBIDDEN)
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java
index 5ea27f8..b028802 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java
@@ -1,10 +1,16 @@
 package com.epam.datalab.backendapi.service.impl;
 
+import com.epam.datalab.auth.UserInfo;
 import com.epam.datalab.backendapi.annotation.Audit;
+import com.epam.datalab.backendapi.dao.EndpointDAO;
+import com.epam.datalab.backendapi.domain.EndpointDTO;
+import com.epam.datalab.backendapi.resources.dto.YmlDTO;
 import com.epam.datalab.exceptions.DynamicChangePropertiesException;
+import com.epam.datalab.rest.client.RESTService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.io.FileUtils;
 
+import javax.inject.Inject;
 import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileWriter;
@@ -16,6 +22,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import java.util.stream.Collectors;
 
 import static com.epam.datalab.backendapi.domain.AuditActionEnum.RECONFIGURE;
 import static com.epam.datalab.backendapi.domain.AuditResourceTypeEnum.EDGE_NODE;
@@ -23,19 +30,9 @@ import static com.epam.datalab.backendapi.domain.AuditResourceTypeEnum.EDGE_NODE
 @Slf4j
 public class DynamicChangeProperties {
 
-    private static final String SELF_SERVICE = "self-service.yml";
-    //services/self-service/self-service.yml";
-    private static final String SELF_SERVICE_PROP_PATH = "/opt/datalab/conf/self-service.yml";
+
     private static final String SELF_SERVICE_SUPERVISORCTL_RUN_NAME = " ui ";
-    private static final String PROVISIONING_SERVICE = "provisioning.yml";
-    //"services/provisioning-service/provisioning.yml";
-    private static final String PROVISIONING_SERVICE_PROP_PATH = "/opt/datalab/conf/provisioning.yml";
     private static final String PROVISIONING_SERVICE_SUPERVISORCTL_RUN_NAME = " provserv ";
-    private static final String BILLING_SERVICE = "billing.yml";
-    //"services/billing-aws/billing.yml";
-    //"services/billing-azure/billing.yml";
-    //"services/billing-gcp/billing.yml";
-    private static final String BILLING_SERVICE_PROP_PATH = "/opt/datalab/conf/billing.yml";
     private static final String BILLING_SERVICE_SUPERVISORCTL_RUN_NAME = " billing ";
     private static final String SECRET_REGEX = "((.*)[sS]ecret(.*)|password): (.*)";
     private static final String SECRET_REPLACEMENT_FORMAT = " ***********";
@@ -65,39 +62,73 @@ public class DynamicChangeProperties {
                     "# specific language governing permissions and limitations\n" +
                     "# under the License.\n" +
                     "#\n" +
-                    "# ******************************************************************************\n";
+                    "# ******************************************************************************";
 
     private static final int DEFAULT_VALUE_PLACE = 1;
     private static final int DEFAULT_NAME_PLACE = 0;
 
-    @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static String getSelfServiceProperties() {
-        return readFileAsString(SELF_SERVICE_PROP_PATH, SELF_SERVICE);
-    }
+    @Inject
+    private static RESTService externalSelfService;
+    @Inject
+    private static EndpointDAO endpointDAO;
 
     @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static String getProvisioningServiceProperties() {
-        return readFileAsString(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE);
+    public static String getProperties(String path, String name) {
+        return readFileAsString(path, name);
     }
 
     @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static String getBillingServiceProperties() {
-        return readFileAsString(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE);
+    public static void overwriteProperties(String path, String name, String ymlString) {
+        writeFileFromString(ymlString, name, path);
     }
 
     @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static void overwriteSelfServiceProperties(String ymlString) {
-        writeFileFromString(ymlString, SELF_SERVICE, SELF_SERVICE_PROP_PATH);
+    public static Map<String, String> getPropertiesWithExternal(String path, String name, UserInfo userInfo) {
+        List<EndpointDTO> externalEndpoints = endpointDAO.getEndpointsWithStatus("ACTIVE");
+        Map<String, String> endpoints = externalEndpoints.stream()
+                .filter(endpointDTO -> !endpointDTO.getName().equals("Local"))
+                .collect(Collectors.toMap(EndpointDTO::getName,
+                        dto -> readFileAsString(path, name, dto, userInfo)));
+        endpoints.put("Local", getProperties(path, name));
+        return endpoints;
+
     }
 
     @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static void overwriteProvisioningServiceProperties(String ymlString) {
-        writeFileFromString(ymlString, PROVISIONING_SERVICE, PROVISIONING_SERVICE_PROP_PATH);
+    public static void overwritePropertiesWithExternal(String path, String name, Map<String, YmlDTO> ymlDTOS,
+                                                       UserInfo userInfo) {
+
+        List<EndpointDTO> allEndpoints = endpointDAO.getEndpointsWithStatus("ACTIVE");
+        Map<EndpointDTO, String> endpointsToChange = allEndpoints.stream()
+                .filter(e -> ymlDTOS.containsKey(e.getName()))
+                .filter(e -> !e.getName().equals("Local"))
+                .collect(Collectors.toMap(e -> e, e -> ymlDTOS.get(e.getName()).getYmlString()));
+
+        endpointsToChange.forEach((endpoint, ymlString) -> {
+            log.info("Trying to write {}, for external endpoint : {} , for user: {}",
+                    name, endpoint.getName(), userInfo.getSimpleName());
+            String url = endpoint.getUrl() + "/api/configuration/" + findMethodName(name);
+            externalSelfService.post(url, ymlString, userInfo.getAccessToken(), String.class);
+        });
+        if (ymlDTOS.containsKey("Local")) {
+            overwriteProperties(path, name, ymlDTOS.get("Local").getYmlString());
+        }
     }
 
-    @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static void overwriteBillingServiceProperties(String ymlString) {
-        writeFileFromString(ymlString, BILLING_SERVICE, BILLING_SERVICE_PROP_PATH);
+    private static String findMethodName(String name) {
+        switch (name) {
+            case "self-service.yml": {
+                return "self-service";
+            }
+            case "provisioning.yml": {
+                return "provisioning-service";
+            }
+            case "billing.yml": {
+                return "billing";
+            }
+            default:
+                return "";
+        }
     }
 
     public static void restart(boolean billing, boolean provserv, boolean ui) {
@@ -130,6 +161,14 @@ public class DynamicChangeProperties {
         }
     }
 
+    private static String readFileAsString(String selfServicePropPath, String serviceName, EndpointDTO endpoint, UserInfo userInfo) {
+        log.info("Trying to read self-service.yml, for external endpoint : {} , for user: {}",
+                endpoint, userInfo.getSimpleName());
+        String currentConf = externalSelfService.get(endpoint.getUrl() + "/api/admin/self-service",
+                userInfo.getAccessToken(), String.class);
+        return hideSecretsAndRemoveLicence(currentConf);
+    }
+
     private static String hideSecretsAndRemoveLicence(String currentConf) {
         Matcher m = Pattern.compile(SECRET_REGEX).matcher(currentConf);
         List<String> secrets = new ArrayList<>();
@@ -164,7 +203,6 @@ public class DynamicChangeProperties {
             log.error("Failed during overwriting {}", serviceName);
             throw new DynamicChangePropertiesException(String.format("Failed during overwriting %s", serviceName));
         }
-
     }
 
     private static void changeCHMODE(String serviceName, String path, String fromMode, String toMode) throws IOException {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org


[incubator-datalab] 01/04: [DATALAB-1716] - showed absent values in "Billing report"

Posted by yk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ykinash pushed a commit to branch DATALAB-2228
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit b1dbf997390af7ebd5601a8a60e71d1726875451
Author: KinashYurii <ur...@gmail.com>
AuthorDate: Thu Feb 11 16:19:08 2021 +0200

    [DATALAB-1716] - showed absent values in "Billing report"
---
 .../datalab/backendapi/domain/BillingReport.java   |  4 ++
 .../backendapi/domain/BillingReportLine.java       |  4 ++
 .../CheckInfrastructureStatusScheduler.java        | 13 ++---
 .../service/impl/BillingServiceImpl.java           | 65 ++++++++++------------
 4 files changed, 41 insertions(+), 45 deletions(-)

diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReport.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReport.java
index 2d550df..8a6170a 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReport.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReport.java
@@ -20,14 +20,18 @@
 package com.epam.datalab.backendapi.domain;
 
 import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.time.LocalDate;
 import java.util.List;
 
 @Data
 @Builder
+@AllArgsConstructor
+@NoArgsConstructor
 public class BillingReport {
     private String sbn;
     private String name;
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReportLine.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReportLine.java
index 8268652..7d98028 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReportLine.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/domain/BillingReportLine.java
@@ -23,14 +23,18 @@ import com.epam.datalab.dto.UserInstanceStatus;
 import com.epam.datalab.dto.billing.BillingResourceType;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.AllArgsConstructor;
 import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.time.LocalDate;
 
 @Data
 @Builder
 @JsonIgnoreProperties(ignoreUnknown = true)
+@AllArgsConstructor
+@NoArgsConstructor
 public class BillingReportLine {
     private String datalabId;
     private String application;
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/schedulers/CheckInfrastructureStatusScheduler.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/schedulers/CheckInfrastructureStatusScheduler.java
index e3a0c95..068c2f9 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/schedulers/CheckInfrastructureStatusScheduler.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/schedulers/CheckInfrastructureStatusScheduler.java
@@ -35,19 +35,16 @@ import com.epam.datalab.dto.base.DataEngineType;
 import com.epam.datalab.dto.status.EnvResource;
 import com.epam.datalab.model.ResourceType;
 import com.google.inject.Inject;
+import lombok.extern.slf4j.Slf4j;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 
-import java.util.Collections;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
 @Scheduled("checkInfrastructureStatusScheduler")
+@Slf4j
 public class CheckInfrastructureStatusScheduler implements Job {
 
     private static final List<UserInstanceStatus> statusesToCheck = Arrays.asList(UserInstanceStatus.RUNNING, UserInstanceStatus.STOPPED);
@@ -90,9 +87,9 @@ public class CheckInfrastructureStatusScheduler implements Job {
                 .map(this::getClusterInstances)
                 .flatMap(Collection::stream)
                 .collect(Collectors.groupingBy(EnvResource::getEndpoint));
-
         activeEndpoints.forEach(e -> {
-                    List<EnvResource> hostInstances = Stream.of(getEdgeInstances(e), exploratoryAndSparkInstances.get(e))
+                    List<EnvResource> hostInstances = Stream.of(getEdgeInstances(e),
+                            exploratoryAndSparkInstances.getOrDefault(e, Collections.emptyList()))
                             .flatMap(Collection::stream)
                             .collect(Collectors.toList());
 
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java
index b697b92..df800e0 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/BillingServiceImpl.java
@@ -24,12 +24,7 @@ import com.epam.datalab.backendapi.conf.SelfServiceApplicationConfiguration;
 import com.epam.datalab.backendapi.dao.BillingDAO;
 import com.epam.datalab.backendapi.dao.ImageExploratoryDAO;
 import com.epam.datalab.backendapi.dao.ProjectDAO;
-import com.epam.datalab.backendapi.domain.BillingReport;
-import com.epam.datalab.backendapi.domain.BillingReportLine;
-import com.epam.datalab.backendapi.domain.BudgetDTO;
-import com.epam.datalab.backendapi.domain.EndpointDTO;
-import com.epam.datalab.backendapi.domain.ProjectDTO;
-import com.epam.datalab.backendapi.domain.ProjectEndpointDTO;
+import com.epam.datalab.backendapi.domain.*;
 import com.epam.datalab.backendapi.resources.dto.BillingFilter;
 import com.epam.datalab.backendapi.resources.dto.ExportBillingFilter;
 import com.epam.datalab.backendapi.resources.dto.QuotaUsageDTO;
@@ -59,16 +54,7 @@ import java.math.BigDecimal;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.time.LocalDate;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
+import java.util.*;
 import java.util.function.Supplier;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
@@ -83,21 +69,21 @@ public class BillingServiceImpl implements BillingService {
     private final EndpointService endpointService;
     private final ExploratoryService exploratoryService;
     private final SelfServiceApplicationConfiguration configuration;
-    private final RESTService provisioningService;
+    private final RESTService billingService;
     private final ImageExploratoryDAO imageExploratoryDao;
     private final BillingDAO billingDAO;
 
     @Inject
     public BillingServiceImpl(ProjectService projectService, ProjectDAO projectDAO, EndpointService endpointService,
                               ExploratoryService exploratoryService, SelfServiceApplicationConfiguration configuration,
-                              @Named(ServiceConsts.BILLING_SERVICE_NAME) RESTService provisioningService, ImageExploratoryDAO imageExploratoryDao,
-                              BillingDAO billingDAO) {
+                              @Named(ServiceConsts.BILLING_SERVICE_NAME) RESTService billingService,
+                              ImageExploratoryDAO imageExploratoryDao, BillingDAO billingDAO) {
         this.projectService = projectService;
         this.projectDAO = projectDAO;
         this.endpointService = endpointService;
         this.exploratoryService = exploratoryService;
         this.configuration = configuration;
-        this.provisioningService = provisioningService;
+        this.billingService = billingService;
         this.imageExploratoryDao = imageExploratoryDao;
         this.billingDAO = billingDAO;
     }
@@ -126,17 +112,17 @@ public class BillingServiceImpl implements BillingService {
                 .build();
     }
 
-	@Override
-	public String downloadReport(UserInfo user, ExportBillingFilter filter, String locale) {
-		BillingReport report = getBillingReport(user, filter);
-		boolean isReportComplete = report.isReportHeaderCompletable();
-		StringBuilder reportHead = new StringBuilder(BillingUtils.getFirstLine(report.getSbn(), report.getUsageDateFrom(), report.getUsageDateTo(), locale));
-		String stringOfAdjustedHeader = BillingUtils.getHeader(isReportComplete);
-		reportHead.append(stringOfAdjustedHeader);
-		report.getReportLines().forEach(r -> reportHead.append(BillingUtils.printLine(r, isReportComplete)));
-		reportHead.append(BillingUtils.getTotal(report.getTotalCost(), report.getCurrency(), stringOfAdjustedHeader));
-		return reportHead.toString();
-	}
+    @Override
+    public String downloadReport(UserInfo user, ExportBillingFilter filter, String locale) {
+        BillingReport report = getBillingReport(user, filter);
+        boolean isReportComplete = report.isReportHeaderCompletable();
+        StringBuilder reportHead = new StringBuilder(BillingUtils.getFirstLine(report.getSbn(), report.getUsageDateFrom(), report.getUsageDateTo(), locale));
+        String stringOfAdjustedHeader = BillingUtils.getHeader(isReportComplete);
+        reportHead.append(stringOfAdjustedHeader);
+        report.getReportLines().forEach(r -> reportHead.append(BillingUtils.printLine(r, isReportComplete)));
+        reportHead.append(BillingUtils.getTotal(report.getTotalCost(), report.getCurrency(), stringOfAdjustedHeader));
+        return reportHead.toString();
+    }
 
     @Override
     public BillingReport getExploratoryBillingData(String project, String endpoint, String exploratoryName, List<String> compNames) {
@@ -174,6 +160,7 @@ public class BillingServiceImpl implements BillingService {
             log.info("Updating billing information for endpoint {}. Billing data {}", endpointDTO.getName(), billingData);
             if (!billingData.isEmpty()) {
                 updateBillingData(endpointDTO, billingData, endpoints);
+                log.info("Updating billing information for endpoint {}. Billing data {} success", endpointDTO.getName(), billingData);
             }
         });
     }
@@ -254,10 +241,10 @@ public class BillingServiceImpl implements BillingService {
                 .stream()
                 .peek(bd -> bd.setApplication(endpointName))
                 .map(bd -> toBillingReport(bd, getOrDefault(billableResources, bd.getTag())));
-
         if (cloudProvider == CloudProvider.GCP) {
             final Map<String, List<BillingReportLine>> gcpBillingData = billingReportLineStream
-                    .collect(Collectors.groupingBy(bd -> bd.getUsageDate().substring(0, USAGE_DATE_FORMAT.length())));
+//                    .collect(Collectors.groupingBy(bd -> bd.getUsageDate().substring(0, USAGE_DATE_FORMAT.length())));
+                    .collect(Collectors.groupingBy(BillingReportLine::getUsageDate));
             updateGcpBillingData(endpointName, gcpBillingData);
         } else if (cloudProvider == CloudProvider.AWS) {
             final Map<String, List<BillingReportLine>> awsBillingData = billingReportLineStream
@@ -275,6 +262,10 @@ public class BillingServiceImpl implements BillingService {
     }
 
     private void updateGcpBillingData(String endpointName, Map<String, List<BillingReportLine>> billingData) {
+        log.info("!!!TEST OUT!!! BillingReportLine: {}", billingData);
+        log.info("!!!TEST OUT!!! endpointName: {}", endpointName);
+
+
         billingData.forEach((usageDate, billingReportLines) -> {
             billingDAO.deleteByUsageDateRegex(endpointName, usageDate);
             billingDAO.save(billingReportLines);
@@ -294,7 +285,7 @@ public class BillingServiceImpl implements BillingService {
 
     private List<BillingData> getBillingData(UserInfo userInfo, EndpointDTO endpointDTO) {
         try {
-            return provisioningService.get(getBillingUrl(endpointDTO.getUrl(), BILLING_PATH), userInfo.getAccessToken(),
+            return billingService.get(getBillingUrl(endpointDTO.getUrl(), BILLING_PATH), userInfo.getAccessToken(),
                     new GenericType<List<BillingData>>() {
                     });
         } catch (Exception e) {
@@ -312,9 +303,9 @@ public class BillingServiceImpl implements BillingService {
             throw new DatalabException("Wrong URI syntax");
         }
         return new URIBuilder()
-		        .setScheme(uri.getScheme())
-		        .setHost(uri.getHost())
-		        .setPort(configuration.getBillingPort())
+                .setScheme(uri.getScheme())
+                .setHost(uri.getHost())
+                .setPort(configuration.getBillingPort())
                 .setPath(path)
                 .toString();
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org


[incubator-datalab] 04/04: [DATALAB-2228] - added possibility of change properties on external endpoint

Posted by yk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

ykinash pushed a commit to branch DATALAB-2228
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git

commit 81ef75a5357a139e02f4516cf1ef0d6a1703c7f7
Author: KinashYurii <ur...@gmail.com>
AuthorDate: Mon Feb 15 13:55:24 2021 +0200

    [DATALAB-2228] - added possibility of change properties on external endpoint
---
 .../resources/admin/ChangePropertiesResource.java  | 50 ++++++++++-------
 .../service/impl/DynamicChangeProperties.java      | 65 +++++++++++-----------
 2 files changed, 61 insertions(+), 54 deletions(-)

diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java
index 1c51385..c368102 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/admin/ChangePropertiesResource.java
@@ -7,16 +7,16 @@ import com.epam.datalab.backendapi.service.impl.DynamicChangeProperties;
 import io.dropwizard.auth.Auth;
 import lombok.NoArgsConstructor;
 
+import javax.inject.Inject;
 import javax.ws.rs.*;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 import java.util.List;
 import java.util.Map;
 
-@Path("configuration")
+@Path("config")
 @Produces(MediaType.APPLICATION_JSON)
 @Consumes(MediaType.APPLICATION_JSON)
-@NoArgsConstructor
 public class ChangePropertiesResource {
 
     private static final String SELF_SERVICE = "self-service.yml";
@@ -31,12 +31,20 @@ public class ChangePropertiesResource {
     //"services/billing-gcp/billing.yml";
     private static final String BILLING_SERVICE_PROP_PATH = "/opt/datalab/conf/billing.yml";
 
+    private final DynamicChangeProperties dynamicChangeProperties;
+
+    @Inject
+    public ChangePropertiesResource(DynamicChangeProperties dynamicChangeProperties) {
+        this.dynamicChangeProperties = dynamicChangeProperties;
+    }
+
+
     @GET
     @Path("/self-service")
     public Response getSelfServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getProperties(SELF_SERVICE_PROP_PATH, SELF_SERVICE))
+                    .ok(dynamicChangeProperties.getProperties(SELF_SERVICE_PROP_PATH, SELF_SERVICE))
                     .build();
         } else {
             return Response
@@ -50,7 +58,7 @@ public class ChangePropertiesResource {
     public Response getProvisioningServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getProperties(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE))
+                    .ok(dynamicChangeProperties.getProperties(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE))
                     .build();
         } else {
             return Response
@@ -64,7 +72,7 @@ public class ChangePropertiesResource {
     public Response getBillingServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getProperties(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE))
+                    .ok(dynamicChangeProperties.getProperties(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE))
                     .build();
         } else {
             return Response
@@ -77,7 +85,7 @@ public class ChangePropertiesResource {
     @Path("/self-service")
     public Response overwriteSelfServiceProperties(@Auth UserInfo userInfo, YmlDTO ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwriteProperties(SELF_SERVICE_PROP_PATH, SELF_SERVICE, ymlDTO.getYmlString());
+            dynamicChangeProperties.overwriteProperties(SELF_SERVICE_PROP_PATH, SELF_SERVICE, ymlDTO.getYmlString());
             return Response.ok().build();
         } else {
             return Response
@@ -90,7 +98,7 @@ public class ChangePropertiesResource {
     @Path("/provisioning-service")
     public Response overwriteProvisioningServiceProperties(@Auth UserInfo userInfo, YmlDTO ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwriteProperties(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE,
+            dynamicChangeProperties.overwriteProperties(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE,
                     ymlDTO.getYmlString());
             return Response.ok().build();
         } else {
@@ -104,7 +112,7 @@ public class ChangePropertiesResource {
     @Path("/billing")
     public Response overwriteBillingServiceProperties(@Auth UserInfo userInfo, YmlDTO ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwriteProperties(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, ymlDTO.getYmlString());
+            dynamicChangeProperties.overwriteProperties(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, ymlDTO.getYmlString());
             return Response.ok().build();
         } else {
             return Response
@@ -114,11 +122,11 @@ public class ChangePropertiesResource {
     }
 
     @GET
-    @Path("multiple/self-service")
+    @Path("/multiple/self-service")
     public Response getAllSelfServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getPropertiesWithExternal(SELF_SERVICE_PROP_PATH, SELF_SERVICE, userInfo))
+                    .ok(dynamicChangeProperties.getPropertiesWithExternal(SELF_SERVICE_PROP_PATH, SELF_SERVICE, userInfo))
                     .build();
         } else {
             return Response
@@ -128,11 +136,11 @@ public class ChangePropertiesResource {
     }
 
     @GET
-    @Path("multiple/provisioning-service")
+    @Path("/multiple/provisioning-service")
     public Response getAllProvisioningServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getPropertiesWithExternal(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE, userInfo))
+                    .ok(dynamicChangeProperties.getPropertiesWithExternal(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE, userInfo))
                     .build();
         } else {
             return Response
@@ -142,11 +150,11 @@ public class ChangePropertiesResource {
     }
 
     @GET
-    @Path("multiple/billing")
+    @Path("/multiple/billing")
     public Response getAllBillingServiceProperties(@Auth UserInfo userInfo) {
         if (UserRoles.isAdmin(userInfo)) {
             return Response
-                    .ok(DynamicChangeProperties.getPropertiesWithExternal(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, userInfo))
+                    .ok(dynamicChangeProperties.getPropertiesWithExternal(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, userInfo))
                     .build();
         } else {
             return Response
@@ -156,10 +164,10 @@ public class ChangePropertiesResource {
     }
 
     @POST
-    @Path("multiple/self-service")
+    @Path("/multiple/self-service")
     public Response overwriteAllSelfServiceProperties(@Auth UserInfo userInfo, Map<String, YmlDTO> ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwritePropertiesWithExternal(SELF_SERVICE_PROP_PATH, SELF_SERVICE, ymlDTO, userInfo);
+            dynamicChangeProperties.overwritePropertiesWithExternal(SELF_SERVICE_PROP_PATH, SELF_SERVICE, ymlDTO, userInfo);
             return Response.ok().build();
         } else {
             return Response
@@ -169,10 +177,10 @@ public class ChangePropertiesResource {
     }
 
     @POST
-    @Path("multiple/provisioning-service")
+    @Path("/multiple/provisioning-service")
     public Response overwriteAllProvisioningServiceProperties(@Auth UserInfo userInfo, Map<String, YmlDTO> ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwritePropertiesWithExternal(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE,
+            dynamicChangeProperties.overwritePropertiesWithExternal(PROVISIONING_SERVICE_PROP_PATH, PROVISIONING_SERVICE,
                     ymlDTO, userInfo);
             return Response.ok().build();
         } else {
@@ -183,10 +191,10 @@ public class ChangePropertiesResource {
     }
 
     @POST
-    @Path("multiple/billing")
+    @Path("/multiple/billing")
     public Response overwriteAllBillingServiceProperties(@Auth UserInfo userInfo, Map<String, YmlDTO> ymlDTO) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.overwritePropertiesWithExternal(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, ymlDTO,
+            dynamicChangeProperties.overwritePropertiesWithExternal(BILLING_SERVICE_PROP_PATH, BILLING_SERVICE, ymlDTO,
                     userInfo);
             return Response.ok().build();
         } else {
@@ -204,7 +212,7 @@ public class ChangePropertiesResource {
                             @QueryParam("ui") boolean ui,
                             @QueryParam("endpoints") List<String> endpoints) {
         if (UserRoles.isAdmin(userInfo)) {
-            DynamicChangeProperties.restart(billing, provserv, ui);
+            dynamicChangeProperties.restart(billing, provserv, ui);
             return Response.ok().build();
         } else {
             return Response
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java
index b028802..cbc315a 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/DynamicChangeProperties.java
@@ -30,7 +30,6 @@ import static com.epam.datalab.backendapi.domain.AuditResourceTypeEnum.EDGE_NODE
 @Slf4j
 public class DynamicChangeProperties {
 
-
     private static final String SELF_SERVICE_SUPERVISORCTL_RUN_NAME = " ui ";
     private static final String PROVISIONING_SERVICE_SUPERVISORCTL_RUN_NAME = " provserv ";
     private static final String BILLING_SERVICE_SUPERVISORCTL_RUN_NAME = " billing ";
@@ -67,55 +66,55 @@ public class DynamicChangeProperties {
     private static final int DEFAULT_VALUE_PLACE = 1;
     private static final int DEFAULT_NAME_PLACE = 0;
 
+
+    private final RESTService externalSelfService;
+    private final EndpointDAO endpointDAO;
+
     @Inject
-    private static RESTService externalSelfService;
-    @Inject
-    private static EndpointDAO endpointDAO;
+    public DynamicChangeProperties(RESTService externalSelfService, EndpointDAO endpointDAO) {
+        this.externalSelfService = externalSelfService;
+        this.endpointDAO = endpointDAO;
+    }
 
-    @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static String getProperties(String path, String name) {
+    public String getProperties(String path, String name) {
         return readFileAsString(path, name);
     }
 
-    @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static void overwriteProperties(String path, String name, String ymlString) {
+    public void overwriteProperties(String path, String name, String ymlString) {
         writeFileFromString(ymlString, name, path);
     }
 
-    @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static Map<String, String> getPropertiesWithExternal(String path, String name, UserInfo userInfo) {
+    public Map<String, String> getPropertiesWithExternal(String path, String name, UserInfo userInfo) {
         List<EndpointDTO> externalEndpoints = endpointDAO.getEndpointsWithStatus("ACTIVE");
         Map<String, String> endpoints = externalEndpoints.stream()
-                .filter(endpointDTO -> !endpointDTO.getName().equals("Local"))
+                .filter(endpointDTO -> !endpointDTO.getName().equals("local"))
                 .collect(Collectors.toMap(EndpointDTO::getName,
                         dto -> readFileAsString(path, name, dto, userInfo)));
-        endpoints.put("Local", getProperties(path, name));
+        endpoints.put("local", getProperties(path, name));
         return endpoints;
 
     }
 
-    @Audit(action = RECONFIGURE, type = EDGE_NODE)
-    public static void overwritePropertiesWithExternal(String path, String name, Map<String, YmlDTO> ymlDTOS,
-                                                       UserInfo userInfo) {
+    public void overwritePropertiesWithExternal(String path, String name, Map<String, YmlDTO> ymlDTOS,
+                                                UserInfo userInfo) {
 
         List<EndpointDTO> allEndpoints = endpointDAO.getEndpointsWithStatus("ACTIVE");
         Map<EndpointDTO, String> endpointsToChange = allEndpoints.stream()
                 .filter(e -> ymlDTOS.containsKey(e.getName()))
-                .filter(e -> !e.getName().equals("Local"))
+                .filter(e -> !e.getName().equals("local"))
                 .collect(Collectors.toMap(e -> e, e -> ymlDTOS.get(e.getName()).getYmlString()));
-
         endpointsToChange.forEach((endpoint, ymlString) -> {
             log.info("Trying to write {}, for external endpoint : {} , for user: {}",
                     name, endpoint.getName(), userInfo.getSimpleName());
-            String url = endpoint.getUrl() + "/api/configuration/" + findMethodName(name);
+            String url = endpoint.getUrl() + "/api/admin/" + findMethodName(name);
             externalSelfService.post(url, ymlString, userInfo.getAccessToken(), String.class);
         });
-        if (ymlDTOS.containsKey("Local")) {
-            overwriteProperties(path, name, ymlDTOS.get("Local").getYmlString());
+        if (ymlDTOS.containsKey("local")) {
+            overwriteProperties(path, name, ymlDTOS.get("local").getYmlString());
         }
     }
 
-    private static String findMethodName(String name) {
+    private String findMethodName(String name) {
         switch (name) {
             case "self-service.yml": {
                 return "self-service";
@@ -131,7 +130,7 @@ public class DynamicChangeProperties {
         }
     }
 
-    public static void restart(boolean billing, boolean provserv, boolean ui) {
+    public void restart(boolean billing, boolean provserv, boolean ui) {
         try {
             String shCommand = buildSHRestartCommand(billing, provserv, ui);
             log.info("Tying to restart ui: {}, provserv: {}, billing: {}, with command: {}", ui,
@@ -142,7 +141,7 @@ public class DynamicChangeProperties {
         }
     }
 
-    private static String buildSHRestartCommand(boolean billing, boolean provserv, boolean ui) {
+    private String buildSHRestartCommand(boolean billing, boolean provserv, boolean ui) {
         StringBuilder stringBuilder = new StringBuilder(SUPERVISORCTL_RESTART_SH_COMMAND);
         if (billing) stringBuilder.append(BILLING_SERVICE_SUPERVISORCTL_RUN_NAME);
         if (provserv) stringBuilder.append(PROVISIONING_SERVICE_SUPERVISORCTL_RUN_NAME);
@@ -150,7 +149,7 @@ public class DynamicChangeProperties {
         return stringBuilder.toString();
     }
 
-    private static String readFileAsString(String selfServicePropPath, String serviceName) {
+    private String readFileAsString(String selfServicePropPath, String serviceName) {
         try {
             log.info("Trying to read self-service.yml, file from path {} :", selfServicePropPath);
             String currentConf = FileUtils.readFileToString(new File(selfServicePropPath), Charset.defaultCharset());
@@ -161,7 +160,7 @@ public class DynamicChangeProperties {
         }
     }
 
-    private static String readFileAsString(String selfServicePropPath, String serviceName, EndpointDTO endpoint, UserInfo userInfo) {
+    private String readFileAsString(String selfServicePropPath, String serviceName, EndpointDTO endpoint, UserInfo userInfo) {
         log.info("Trying to read self-service.yml, for external endpoint : {} , for user: {}",
                 endpoint, userInfo.getSimpleName());
         String currentConf = externalSelfService.get(endpoint.getUrl() + "/api/admin/self-service",
@@ -169,7 +168,7 @@ public class DynamicChangeProperties {
         return hideSecretsAndRemoveLicence(currentConf);
     }
 
-    private static String hideSecretsAndRemoveLicence(String currentConf) {
+    private String hideSecretsAndRemoveLicence(String currentConf) {
         Matcher m = Pattern.compile(SECRET_REGEX).matcher(currentConf);
         List<String> secrets = new ArrayList<>();
         String confWithReplacedSecretConf = removeLicence(currentConf);
@@ -184,11 +183,11 @@ public class DynamicChangeProperties {
         return confWithReplacedSecretConf;
     }
 
-    private static String removeLicence(String conf) {
+    private String removeLicence(String conf) {
         return conf.split(LICENCE_REGEX)[conf.split(LICENCE_REGEX).length - 1];
     }
 
-    private static void writeFileFromString(String newPropFile, String serviceName, String servicePath) {
+    private void writeFileFromString(String newPropFile, String serviceName, String servicePath) {
         try {
             String oldFile = FileUtils.readFileToString(new File(servicePath), Charset.defaultCharset());
             changeCHMODE(serviceName, servicePath, DEFAULT_CHMOD, WRITE_CHMOD);
@@ -205,7 +204,7 @@ public class DynamicChangeProperties {
         }
     }
 
-    private static void changeCHMODE(String serviceName, String path, String fromMode, String toMode) throws IOException {
+    private void changeCHMODE(String serviceName, String path, String fromMode, String toMode) throws IOException {
         try {
             String command = String.format(CHANGE_CHMOD_SH_COMMAND_FORMAT, toMode, path);
             log.info("Trying to change chmod for file {} {}->{}", serviceName, fromMode, toMode);
@@ -216,16 +215,16 @@ public class DynamicChangeProperties {
         }
     }
 
-    private static String addLicence() {
+    private String addLicence() {
         return LICENCE;
     }
 
-    private static String checkAndReplaceSecretIfEmpty(String newPropFile, String oldProf) {
+    private String checkAndReplaceSecretIfEmpty(String newPropFile, String oldProf) {
         Map<String, String> emptySecrets = findEmptySecret(newPropFile);
         return emptySecrets.isEmpty() ? newPropFile : replaceEmptySecret(newPropFile, oldProf, emptySecrets);
     }
 
-    private static String replaceEmptySecret(String newPropFile, String oldProf, Map<String, String> emptySecrets) {
+    private String replaceEmptySecret(String newPropFile, String oldProf, Map<String, String> emptySecrets) {
         String fileWithReplacedEmptySecrets = newPropFile;
         Matcher oldProfMatcher = Pattern.compile(SECRET_REGEX).matcher(oldProf);
         while (oldProfMatcher.find()) {
@@ -237,7 +236,7 @@ public class DynamicChangeProperties {
         return fileWithReplacedEmptySecrets;
     }
 
-    private static Map<String, String> findEmptySecret(String newPropFile) {
+    private Map<String, String> findEmptySecret(String newPropFile) {
         Matcher newPropFileMatcher = Pattern.compile(SECRET_REGEX).matcher(newPropFile);
         Map<String, String> emptySecrets = new HashMap<>();
         while (newPropFileMatcher.find()) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org