You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@datalab.apache.org by dy...@apache.org on 2022/09/29 15:53:44 UTC
[incubator-datalab] 01/02: add support for connected platforms
This is an automated email from the ASF dual-hosted git repository.
dyankiv pushed a commit to branch DATALAB-3068
in repository https://gitbox.apache.org/repos/asf/incubator-datalab.git
commit 1b7710d868df0bf6d000050e683453374f34fa95
Author: Denys Yankiv <de...@gmail.com>
AuthorDate: Thu Sep 29 18:51:13 2022 +0300
add support for connected platforms
---
.../datalab/backendapi/SelfServiceApplication.java | 1 +
.../backendapi/dao/ConnectedPlatformsDAO.java | 34 ++++++++++
.../backendapi/dao/ConnectedPlatformsDAOImpl.java | 51 ++++++++++++++
.../epam/datalab/backendapi/modules/DevModule.java | 2 +
.../backendapi/modules/ProductionModule.java | 2 +
.../resources/ConnectedPlatformResource.java | 77 ++++++++++++++++++++++
...sPageDTO.java => ConnectedPlatformAddFrom.java} | 51 +++++---------
...tatusPageDTO.java => ConnectedPlatformDTO.java} | 41 +++---------
.../resources/dto/ConnectedPlatformType.java | 28 ++++++++
.../resources/dto/HealthStatusPageDTO.java | 10 +++
.../backendapi/resources/dto/UserRoleDTO.java | 1 +
.../service/ConnectedPlatformsService.java | 34 ++++++++++
.../impl/ConnectedPlatformsServiceImpl.java | 71 ++++++++++++++++++++
.../impl/InfrastructureInfoServiceImpl.java | 10 +++
.../main/resources/mongo/general/mongo_roles.json | 36 ++++++++++
.../impl/InfrastructureInfoServiceImplTest.java | 5 ++
16 files changed, 387 insertions(+), 67 deletions(-)
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
index 50f291431..027ce4fa7 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/SelfServiceApplication.java
@@ -181,6 +181,7 @@ public class SelfServiceApplication extends Application<SelfServiceApplicationCo
jersey.register(injector.getInstance(OdahuResource.class));
jersey.register(injector.getInstance(OdahuCallback.class));
jersey.register(injector.getInstance(ChangePropertiesResource.class));
+ jersey.register(injector.getInstance(ConnectedPlatformResource.class));
}
private void disableGzipHandlerForGuacamoleServlet(Server server) {
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ConnectedPlatformsDAO.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ConnectedPlatformsDAO.java
new file mode 100644
index 000000000..bac441d9f
--- /dev/null
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ConnectedPlatformsDAO.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.datalab.backendapi.dao;
+
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformDTO;
+
+import java.util.List;
+
+public interface ConnectedPlatformsDAO {
+
+ boolean exist(String name);
+ void addPlatform(ConnectedPlatformDTO connectedPlatformDTO);
+
+ List<ConnectedPlatformDTO> getAll();
+
+ void delete(String name);
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ConnectedPlatformsDAOImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ConnectedPlatformsDAOImpl.java
new file mode 100644
index 000000000..d77b51406
--- /dev/null
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/dao/ConnectedPlatformsDAOImpl.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.datalab.backendapi.dao;
+
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformDTO;
+
+import java.util.List;
+import static com.mongodb.client.model.Filters.eq;
+
+public class ConnectedPlatformsDAOImpl extends BaseDAO implements ConnectedPlatformsDAO {
+
+ private static final String CONNECTED_PLATFORMS = "connectedPlatforms";
+ private static final String NAME = "name";
+
+ @Override
+ public boolean exist(String name) {
+ return findOne(CONNECTED_PLATFORMS, eq(NAME, name)).isPresent();
+ }
+
+ @Override
+ public void addPlatform(ConnectedPlatformDTO connectedPlatformDTO) {
+ insertOne(CONNECTED_PLATFORMS, connectedPlatformDTO);
+ }
+
+ @Override
+ public List<ConnectedPlatformDTO> getAll() {
+ return find(CONNECTED_PLATFORMS, ConnectedPlatformDTO.class);
+ }
+
+ @Override
+ public void delete(String name) {
+ deleteOne(CONNECTED_PLATFORMS, eq(NAME,name));
+ }
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/DevModule.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/DevModule.java
index 6da6ee736..69155245b 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/DevModule.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/DevModule.java
@@ -119,6 +119,8 @@ public class DevModule extends ModuleBase<SelfServiceApplicationConfiguration> i
bind(BillingDAO.class).to(BaseBillingDAO.class);
bind(AuditDAO.class).to(AuditDAOImpl.class);
bind(BucketService.class).to(BucketServiceImpl.class);
+ bind(ConnectedPlatformsService.class).to(ConnectedPlatformsServiceImpl.class);
+ bind(ConnectedPlatformsDAO.class).to(ConnectedPlatformsDAOImpl.class);
}
private void configureCors(Environment environment) {
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/ProductionModule.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/ProductionModule.java
index 15df056c5..6d8dc4cd3 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/ProductionModule.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/modules/ProductionModule.java
@@ -111,6 +111,8 @@ public class ProductionModule extends ModuleBase<SelfServiceApplicationConfigura
bind(TagService.class).to(TagServiceImpl.class);
bind(SecurityService.class).to(SecurityServiceImpl.class);
bind(KeycloakService.class).to(KeycloakServiceImpl.class);
+ bind(ConnectedPlatformsService.class).to(ConnectedPlatformsServiceImpl.class);
+ bind(ConnectedPlatformsDAO.class).to(ConnectedPlatformsDAOImpl.class);
bind(Client.class).toInstance(httpClient);
}
}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ConnectedPlatformResource.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ConnectedPlatformResource.java
new file mode 100644
index 000000000..5ec70f3d7
--- /dev/null
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/ConnectedPlatformResource.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.datalab.backendapi.resources;
+
+import com.epam.datalab.auth.UserInfo;
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformAddFrom;
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformType;
+import com.epam.datalab.backendapi.service.ConnectedPlatformsService;
+import com.google.inject.Inject;
+import io.dropwizard.auth.Auth;
+import lombok.extern.slf4j.Slf4j;
+
+import javax.annotation.security.RolesAllowed;
+import javax.validation.Valid;
+import javax.ws.rs.*;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+@Path("connected_platforms")
+@Consumes(MediaType.APPLICATION_JSON)
+@Produces(MediaType.APPLICATION_JSON)
+@Slf4j
+public class ConnectedPlatformResource {
+
+ private final ConnectedPlatformsService connectedPlatformsService;
+
+ @Inject
+ public ConnectedPlatformResource(ConnectedPlatformsService connectedPlatformsService) {
+ this.connectedPlatformsService = connectedPlatformsService;
+ }
+
+ @RolesAllowed("/api/connected_platforms/view")
+ @GET
+ public Response getConnectedPlatforms(@Auth UserInfo ui) {
+ return Response.ok(connectedPlatformsService.getAll()).build();
+ }
+
+ @RolesAllowed("/api/connected_platforms/view")
+ @GET
+ @Path("/types")
+ public Response getConnectedPlatformTypes(@Auth UserInfo ui){
+ return Response.ok(ConnectedPlatformType.values()).build();
+ }
+
+ @RolesAllowed("/api/connected_platforms/add")
+ @POST
+ public Response addConnectedPlatform(@Auth UserInfo ui, @Valid ConnectedPlatformAddFrom from) {
+ connectedPlatformsService.addPlatform(ui, from.getName(), from.getType(), from.getUrl());
+ return Response.ok().build();
+ }
+
+ @RolesAllowed("/api/connected_platforms/disconnect")
+ @DELETE
+ @Path("{name}")
+ public Response disconnectPlatform(@Auth UserInfo ui, @PathParam("name") String platformName) {
+ connectedPlatformsService.disconnect(ui, platformName);
+ return Response.ok().build();
+ }
+
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformAddFrom.java
similarity index 50%
copy from services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
copy to services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformAddFrom.java
index 9db1cfce1..def2ed30a 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformAddFrom.java
@@ -17,43 +17,26 @@
* under the License.
*/
+
package com.epam.datalab.backendapi.resources.dto;
-import com.fasterxml.jackson.annotation.JsonProperty;
-import lombok.Builder;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
+import lombok.NonNull;
+import org.hibernate.validator.constraints.NotBlank;
+import org.hibernate.validator.constraints.URL;
-import java.util.List;
+import javax.validation.Valid;
-/**
- * Stores the health statuses for environment resources.
- */
@Data
-@Builder
-public class HealthStatusPageDTO {
- @JsonProperty
- private String status;
- @JsonProperty("list_resources")
- private List<HealthStatusResource> listResources;
- @JsonProperty
- private boolean billingEnabled;
- @JsonProperty
- private boolean auditEnabled;
- @JsonProperty
- private boolean admin;
- @JsonProperty
- private boolean projectAdmin;
- @JsonProperty
- private boolean projectAssigned;
- @JsonProperty
- private BucketBrowser bucketBrowser;
-
- @Builder
- @Data
- public static class BucketBrowser {
- private final boolean view;
- private final boolean upload;
- private final boolean download;
- private final boolean delete;
- }
-}
\ No newline at end of file
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConnectedPlatformAddFrom {
+ private static final String URL_REGEXP_VALIDATION = "^(http(s)?)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]";
+ @NotBlank(message = "field cannot be empty")
+ private final String name;
+ @URL(regexp = URL_REGEXP_VALIDATION, message = "field is in improper format!")
+ private final String url;
+ @NonNull
+ @Valid
+ private final ConnectedPlatformType type;
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformDTO.java
similarity index 51%
copy from services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
copy to services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformDTO.java
index 9db1cfce1..95149ca30 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformDTO.java
@@ -19,41 +19,16 @@
package com.epam.datalab.backendapi.resources.dto;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Builder;
import lombok.Data;
-import java.util.List;
-
-/**
- * Stores the health statuses for environment resources.
- */
@Data
@Builder
-public class HealthStatusPageDTO {
- @JsonProperty
- private String status;
- @JsonProperty("list_resources")
- private List<HealthStatusResource> listResources;
- @JsonProperty
- private boolean billingEnabled;
- @JsonProperty
- private boolean auditEnabled;
- @JsonProperty
- private boolean admin;
- @JsonProperty
- private boolean projectAdmin;
- @JsonProperty
- private boolean projectAssigned;
- @JsonProperty
- private BucketBrowser bucketBrowser;
-
- @Builder
- @Data
- public static class BucketBrowser {
- private final boolean view;
- private final boolean upload;
- private final boolean download;
- private final boolean delete;
- }
-}
\ No newline at end of file
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class ConnectedPlatformDTO {
+ private final String name;
+ private final ConnectedPlatformType type;
+ private final String user;
+ private final String url;
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformType.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformType.java
new file mode 100644
index 000000000..df438b8fd
--- /dev/null
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/ConnectedPlatformType.java
@@ -0,0 +1,28 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.datalab.backendapi.resources.dto;
+
+public enum ConnectedPlatformType {
+ MLFLOW("MLflow");
+
+ ConnectedPlatformType(String name) {
+
+ }
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
index 9db1cfce1..2b2a23f6f 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/HealthStatusPageDTO.java
@@ -47,6 +47,8 @@ public class HealthStatusPageDTO {
private boolean projectAssigned;
@JsonProperty
private BucketBrowser bucketBrowser;
+ @JsonProperty
+ private ConnectedPlatforms connectedPlatforms;
@Builder
@Data
@@ -56,4 +58,12 @@ public class HealthStatusPageDTO {
private final boolean download;
private final boolean delete;
}
+
+ @Builder
+ @Data
+ public static class ConnectedPlatforms {
+ private final boolean view;
+ private final boolean add;
+ private final boolean disconnect;
+ }
}
\ No newline at end of file
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/UserRoleDTO.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/UserRoleDTO.java
index 45bdca792..cfaa82e7d 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/UserRoleDTO.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/resources/dto/UserRoleDTO.java
@@ -55,6 +55,7 @@ public class UserRoleDTO {
IMAGE,
NOTEBOOK_SHAPE,
COMPUTATIONAL_SHAPE,
+ CONNECTED_PLATFORMS,
BILLING,
BUCKET_BROWSER,
ADMINISTRATION,
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ConnectedPlatformsService.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ConnectedPlatformsService.java
new file mode 100644
index 000000000..8eccd8048
--- /dev/null
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/ConnectedPlatformsService.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.datalab.backendapi.service;
+
+import com.epam.datalab.auth.UserInfo;
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformDTO;
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformType;
+
+import java.util.List;
+
+public interface ConnectedPlatformsService {
+ List<ConnectedPlatformDTO> getAll();
+
+ void addPlatform(UserInfo user, String name, ConnectedPlatformType type, String url);
+
+ void disconnect(UserInfo user, String name);
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ConnectedPlatformsServiceImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ConnectedPlatformsServiceImpl.java
new file mode 100644
index 000000000..34a6d21de
--- /dev/null
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/ConnectedPlatformsServiceImpl.java
@@ -0,0 +1,71 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package com.epam.datalab.backendapi.service.impl;
+
+import com.epam.datalab.auth.UserInfo;
+import com.epam.datalab.backendapi.dao.ConnectedPlatformsDAO;
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformDTO;
+import com.epam.datalab.backendapi.resources.dto.ConnectedPlatformType;
+import com.epam.datalab.backendapi.service.ConnectedPlatformsService;
+import com.epam.datalab.exceptions.ResourceAlreadyExistException;
+import com.google.inject.Inject;
+import com.google.inject.Singleton;
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.List;
+@Singleton
+@Slf4j
+public class ConnectedPlatformsServiceImpl implements ConnectedPlatformsService {
+
+ private static final String CONNECTED_PLATFORM_NAME_EXIST = "Connected platform with name %s already exist";
+ private final ConnectedPlatformsDAO connectedPlatformsDAO;
+
+
+ @Inject
+ public ConnectedPlatformsServiceImpl(ConnectedPlatformsDAO connectedPlatformsDAO) {
+ this.connectedPlatformsDAO = connectedPlatformsDAO;
+ }
+
+
+ @Override
+ public List<ConnectedPlatformDTO> getAll() {
+ return connectedPlatformsDAO.getAll();
+ }
+
+ @Override
+ public void addPlatform(UserInfo user, String name, ConnectedPlatformType type, String url) {
+ if(connectedPlatformsDAO.exist(name)){
+ log.error(String.format(CONNECTED_PLATFORM_NAME_EXIST,name));
+ throw new ResourceAlreadyExistException(String.format(CONNECTED_PLATFORM_NAME_EXIST,name));
+ }
+
+ connectedPlatformsDAO.addPlatform(ConnectedPlatformDTO.builder()
+ .name(name)
+ .url(url)
+ .user(user.getName())
+ .type(type)
+ .build());
+ }
+
+ @Override
+ public void disconnect(UserInfo user, String name) {
+ connectedPlatformsDAO.delete(name);
+ }
+}
diff --git a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImpl.java b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
index 2aca62153..c1b122dd1 100644
--- a/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImpl.java
@@ -60,6 +60,11 @@ public class InfrastructureInfoServiceImpl implements InfrastructureInfoService
private static final String PERMISSION_UPLOAD = "/api/bucket/upload";
private static final String PERMISSION_DOWNLOAD = "/api/bucket/download";
private static final String PERMISSION_DELETE = "/api/bucket/delete";
+
+ private static final String CONNECTED_PLATFORMS_PERMISSION_VIEW = "/api/connected_platforms/view";
+ private static final String CONNECTED_PLATFORMS_PERMISSION_ADD = "/api/connected_platforms/add";
+ private static final String CONNECTED_PLATFORMS_PERMISSION_DISCONNECT = "/api/connected_platforms/disconnect";
+
private static final String INFRASTRUCTURE_STATUS = "infrastructure/status";
private final ExploratoryDAO expDAO;
@@ -124,6 +129,11 @@ public class InfrastructureInfoServiceImpl implements InfrastructureInfoService
.download(checkAccess(userInfo, PERMISSION_DOWNLOAD))
.delete(checkAccess(userInfo, PERMISSION_DELETE))
.build())
+ .connectedPlatforms(HealthStatusPageDTO.ConnectedPlatforms.builder()
+ .view(checkAccess(userInfo, CONNECTED_PLATFORMS_PERMISSION_VIEW))
+ .add(checkAccess(userInfo, CONNECTED_PLATFORMS_PERMISSION_ADD))
+ .disconnect(checkAccess(userInfo, CONNECTED_PLATFORMS_PERMISSION_VIEW))
+ .build())
.build();
}
diff --git a/services/self-service/src/main/resources/mongo/general/mongo_roles.json b/services/self-service/src/main/resources/mongo/general/mongo_roles.json
index e9e53433e..c3cfefe11 100644
--- a/services/self-service/src/main/resources/mongo/general/mongo_roles.json
+++ b/services/self-service/src/main/resources/mongo/general/mongo_roles.json
@@ -95,6 +95,42 @@
"$anyuser"
]
},
+ {
+ "_id": "connectedPlatformsView",
+ "description": "Allow to view connected platforms",
+ "type": "CONNECTED_PLATFORMS",
+ "cloud": "GENERAL",
+ "pages": [
+ "/api/connected_platforms/view"
+ ],
+ "groups": [
+ "$anyuser"
+ ]
+ },
+ {
+ "_id": "connectedPlatformsDisconnect",
+ "description": "Allow to disconnect connected platforms",
+ "type": "CONNECTED_PLATFORMS",
+ "cloud": "GENERAL",
+ "pages": [
+ "/api/connected_platforms/disconnect"
+ ],
+ "groups": [
+ "$anyuser"
+ ]
+ },
+ {
+ "_id": "connectedPlatformsAdd",
+ "description": "Allow to add connected platforms",
+ "type": "CONNECTED_PLATFORMS",
+ "cloud": "GENERAL",
+ "pages": [
+ "/api/connected_platforms/add"
+ ],
+ "groups": [
+ "$anyuser"
+ ]
+ },
{
"_id": "bucketBrowserDelete",
"description": "Allow to delete object via bucket browser",
diff --git a/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImplTest.java b/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImplTest.java
index 683617aa0..93ecc3895 100644
--- a/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImplTest.java
+++ b/services/self-service/src/test/java/com/epam/datalab/backendapi/service/impl/InfrastructureInfoServiceImplTest.java
@@ -255,6 +255,11 @@ public class InfrastructureInfoServiceImplTest extends TestBase {
.download(Boolean.TRUE)
.delete(Boolean.TRUE)
.build())
+ .connectedPlatforms(HealthStatusPageDTO.ConnectedPlatforms.builder()
+ .view(Boolean.TRUE)
+ .add(Boolean.TRUE)
+ .disconnect(Boolean.TRUE)
+ .build())
.build();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@datalab.apache.org
For additional commands, e-mail: commits-help@datalab.apache.org