You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dlab.apache.org by of...@apache.org on 2020/05/25 09:22:11 UTC

[incubator-dlab] branch DLAB-1744 created (now 69c7b48)

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

ofuks pushed a change to branch DLAB-1744
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git.


      at 69c7b48  [DLAB-1744] Conveyed notebook links of other users to administrator

This branch includes the following new commits:

     new 69c7b48  [DLAB-1744] Conveyed notebook links of other users to administrator

The 1 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@dlab.apache.org
For additional commands, e-mail: commits-help@dlab.apache.org


[incubator-dlab] 01/01: [DLAB-1744] Conveyed notebook links of other users to administrator

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

ofuks pushed a commit to branch DLAB-1744
in repository https://gitbox.apache.org/repos/asf/incubator-dlab.git

commit 69c7b48c3b54af578a7ebc6c9062ca55f37a553b
Author: Oleh Fuks <ol...@gmail.com>
AuthorDate: Mon May 25 12:21:51 2020 +0300

    [DLAB-1744] Conveyed notebook links of other users to administrator
---
 .../backendapi/resources/dto/UserResourceInfo.java | 70 ++++------------------
 .../service/impl/EnvironmentServiceImpl.java       | 29 +++++----
 2 files changed, 27 insertions(+), 72 deletions(-)

diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
index ea1198e..5958411 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/resources/dto/UserResourceInfo.java
@@ -18,88 +18,38 @@
  */
 package com.epam.dlab.backendapi.resources.dto;
 
+import com.epam.dlab.dto.ResourceURL;
 import com.epam.dlab.dto.computational.UserComputationalResource;
 import com.epam.dlab.model.ResourceEnum;
 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
 import com.fasterxml.jackson.annotation.JsonProperty;
+import lombok.Builder;
 import lombok.Data;
 
-import java.util.Collections;
 import java.util.List;
 
 @Data
+@Builder
 @JsonIgnoreProperties(ignoreUnknown = true)
 public class UserResourceInfo {
-
+	@JsonProperty
+	private String user;
+	@JsonProperty
+	private String project;
 	@JsonProperty("resource_type")
 	private ResourceEnum resourceType;
-
 	@JsonProperty("resource_name")
 	private String resourceName;
-
 	@JsonProperty("shape")
 	private String resourceShape;
-
 	@JsonProperty("status")
 	private String resourceStatus;
-
 	@JsonProperty("computational_resources")
-	private List<UserComputationalResource> computationalResources = Collections.emptyList();
-
-	@JsonProperty
-	private String user;
-	@JsonProperty
-	private String project;
-
+	private List<UserComputationalResource> computationalResources;
 	@JsonProperty("public_ip")
 	private String ip;
-
 	@JsonProperty("cloud_provider")
 	private String cloudProvider;
-
-
-	public UserResourceInfo withResourceType(ResourceEnum resourceType) {
-		setResourceType(resourceType);
-		return this;
-	}
-
-	public UserResourceInfo withResourceName(String resourceName) {
-		setResourceName(resourceName);
-		return this;
-	}
-
-	public UserResourceInfo withResourceShape(String resourceShape) {
-		setResourceShape(resourceShape);
-		return this;
-	}
-
-	public UserResourceInfo withResourceStatus(String resourceStatus) {
-		setResourceStatus(resourceStatus);
-		return this;
-	}
-
-	public UserResourceInfo withCompResources(List<UserComputationalResource> compResources) {
-		setComputationalResources(compResources);
-		return this;
-	}
-
-	public UserResourceInfo withUser(String user) {
-		setUser(user);
-		return this;
-	}
-
-	public UserResourceInfo withIp(String ip) {
-		setIp(ip);
-		return this;
-	}
-
-	public UserResourceInfo withProject(String project) {
-		setProject(project);
-		return this;
-	}
-
-	public UserResourceInfo withCloudProvider(String cloudProvider) {
-		setCloudProvider(cloudProvider);
-		return this;
-	}
+	@JsonProperty("exploratory_urls")
+	private List<ResourceURL> exploratoryUrls;
 }
diff --git a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
index 8b2806b..6815f9d 100644
--- a/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
+++ b/services/self-service/src/main/java/com/epam/dlab/backendapi/service/impl/EnvironmentServiceImpl.java
@@ -194,10 +194,12 @@ public class EnvironmentServiceImpl implements EnvironmentService {
 		if (projectDTO.getEndpoints() != null) {
 			final Stream<UserResourceInfo> edges = projectDTO.getEndpoints()
 					.stream()
-					.map(e -> new UserResourceInfo().withResourceType(ResourceEnum.EDGE_NODE)
-							.withResourceStatus(e.getStatus().toString())
-							.withProject(projectDTO.getName())
-							.withIp(e.getEdgeInfo() != null ? e.getEdgeInfo().getPublicIp() : null));
+					.map(e -> UserResourceInfo.builder()
+							.resourceType(ResourceEnum.EDGE_NODE)
+							.resourceStatus(e.getStatus().toString())
+							.project(projectDTO.getName())
+							.ip(e.getEdgeInfo() != null ? e.getEdgeInfo().getPublicIp() : null)
+							.build());
 			return Stream.concat(edges, userResources).collect(toList());
 		} else {
 			return userResources.collect(toList());
@@ -205,14 +207,17 @@ public class EnvironmentServiceImpl implements EnvironmentService {
 	}
 
 	private UserResourceInfo toUserResourceInfo(UserInstanceDTO userInstance) {
-		return new UserResourceInfo().withResourceType(ResourceEnum.NOTEBOOK)
-				.withResourceName(userInstance.getExploratoryName())
-				.withResourceShape(userInstance.getShape())
-				.withResourceStatus(userInstance.getStatus())
-				.withCompResources(userInstance.getResources())
-				.withUser(userInstance.getUser())
-				.withProject(userInstance.getProject())
-				.withCloudProvider(userInstance.getCloudProvider());
+		return UserResourceInfo.builder()
+				.resourceType(ResourceEnum.NOTEBOOK)
+				.resourceName(userInstance.getExploratoryName())
+				.resourceShape(userInstance.getShape())
+				.resourceStatus(userInstance.getStatus())
+				.computationalResources(userInstance.getResources())
+				.user(userInstance.getUser())
+				.project(userInstance.getProject())
+				.cloudProvider(userInstance.getCloudProvider())
+				.exploratoryUrls(userInstance.getResourceUrl())
+				.build();
 	}
 
 	private void checkProjectResourceConditions(String project, String action) {


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