Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changed return type from ServerMetadata to Server #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sample/scripts/src/main/java/sample/PoliciesSampleApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void init() {
ZonedDateTime.now().plusHours(2)
)
)
.waitUntilComplete().getResult().asRefById();
.waitUntilComplete().getResult();
}

@AfterClass(groups = {SAMPLES})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,9 @@ public ServerService(ServerConverter serverConverter, ServerClient client, Queue
* Create server
*
* @param config server config
* @return OperationFuture wrapper for ServerMetadata
* @return OperationFuture wrapper for Server
*/
public OperationFuture<ServerMetadata> create(CreateServerConfig config) {
public OperationFuture<Server> create(CreateServerConfig config) {
BaseServerResponse response = client.create(
serverConverter.buildCreateServerRequest(
config,
Expand All @@ -124,9 +124,9 @@ public OperationFuture<ServerMetadata> create(CreateServerConfig config) {
* Clone existing server
*
* @param config server config
* @return OperationFuture wrapper for ServerMetadata
* @return OperationFuture wrapper for Server
*/
public OperationFuture<ServerMetadata> clone(CloneServerConfig config) {
public OperationFuture<Server> clone(CloneServerConfig config) {
BaseServerResponse response = client.clone(
serverConverter.buildCloneServerRequest(
config,
Expand All @@ -145,9 +145,9 @@ public OperationFuture<ServerMetadata> clone(CloneServerConfig config) {
* Import server from ovf image
*
* @param config server config
* @return OperationFuture wrapper for ServerMetadata
* @return OperationFuture wrapper for Server
*/
public OperationFuture<ServerMetadata> importServer(ImportServerConfig config) {
public OperationFuture<Server> importServer(ImportServerConfig config) {
BaseServerResponse response = client.importServer(
serverConverter.buildImportServerRequest(
config,
Expand All @@ -160,15 +160,15 @@ public OperationFuture<ServerMetadata> importServer(ImportServerConfig config) {
return postProcessBuildServerResponse(response, config);
}

private <T extends CreateServerConfig> OperationFuture<ServerMetadata> postProcessBuildServerResponse(
private <T extends CreateServerConfig> OperationFuture<Server> postProcessBuildServerResponse(
BaseServerResponse response,
T config
) {
ServerMetadata serverInfo = client.findServerByUuid(response.findServerUuid());

return
new OperationFuture<>(
serverInfo,
serverInfo.asRefById(),
new SequentialJobsFuture(
() -> new CreateServerJobFuture(response.findStatusId(), serverInfo.getId(), queueClient, client),
() -> addPublicIpIfNeeded(config, serverInfo)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import com.centurylink.cloud.sdk.core.injector.Inject;
import com.centurylink.cloud.sdk.server.services.AbstractServersSdkTest;
import com.centurylink.cloud.sdk.server.services.client.domain.group.GroupMetadata;
import com.centurylink.cloud.sdk.server.services.client.domain.server.metadata.ServerMetadata;
import com.centurylink.cloud.sdk.server.services.dsl.GroupService;
import com.centurylink.cloud.sdk.server.services.dsl.ServerService;
import com.centurylink.cloud.sdk.server.services.dsl.domain.group.BillingStats;
import com.centurylink.cloud.sdk.server.services.dsl.domain.group.GroupConfig;
import com.centurylink.cloud.sdk.server.services.dsl.domain.group.refs.Group;
import com.centurylink.cloud.sdk.server.services.dsl.domain.group.refs.GroupByIdRef;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.Machine;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.refs.Server;
import com.centurylink.cloud.sdk.server.services.dsl.servers.TestServerSupport;
import com.centurylink.cloud.sdk.tests.recorded.WireMockFileSource;
import com.centurylink.cloud.sdk.tests.recorded.WireMockMixin;
Expand All @@ -48,7 +48,7 @@ public class GetBillingStatsTest extends AbstractServersSdkTest implements WireM
@Inject
GroupService groupService;

ServerMetadata serverMetadata;
Server server;

GroupByIdRef group;
GroupMetadata groupMetadata;
Expand All @@ -62,7 +62,7 @@ public void setUp() {
@AfterMethod
public void tearDown() {
serverService
.delete(serverMetadata.asRefById());
.delete(server);

groupService
.delete(group);
Expand All @@ -86,7 +86,7 @@ private void initGroup() {
}

private void initServer() {
serverMetadata = serverService.create(
server = serverService.create(
TestServerSupport
.anyServerConfig()
.name("st-srv")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public static CloneServerConfig getCloneServerConfig(Server server) {
return config;
}

public ServerMetadata createAnyServer() {
public Server createAnyServer() {
return
serverService.create(new CreateServerConfig()
.name("ALTRS1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,19 @@ public class CloneServerTest extends AbstractServersSdkTest implements WireMockM
@Inject
ServerService serverService;

ServerMetadata serverMetadata;
Server server;

@Test
public void testCloneSever() {
Server server = Server.refById("de1altdcln04");

CloneServerConfig config = TestServerSupport.getCloneServerConfig(server);
CloneServerConfig config = TestServerSupport.getCloneServerConfig(Server.refById("de1altdcln04"));

serverMetadata = serverService.clone(config)
server = serverService.clone(config)
.waitUntilComplete()
.getResult();

ServerMetadata serverMetadata = serverService.findByRef(server);

assertNotNull(serverMetadata);
assertNotNull(serverMetadata.getId());
assertEquals(serverMetadata.getLocationId().toLowerCase(), DE_FRANKFURT.getId());
Expand All @@ -57,7 +58,7 @@ public void testCloneSever() {

@AfterMethod
public void deleteServer() {
serverService.delete(serverMetadata.asRefById().asFilter());
serverService.delete(server.asFilter());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import static com.centurylink.cloud.sdk.base.services.dsl.domain.datacenters.refs.DataCenter.CA_TORONTO_2;
import static com.centurylink.cloud.sdk.tests.TestGroups.RECORDED;
import static com.centurylink.cloud.sdk.core.util.Strings.isNullOrEmpty;

/**
* @author Aliaksandr Krasitski
Expand All @@ -46,7 +45,7 @@ public class CreateWithAntiAffinityPolicyTest extends AbstractServersSdkTest imp
@Inject
ServerService serverService;

ServerMetadata server;
Server server;

@Test
@WireMockFileSource("anti-affinity")
Expand Down Expand Up @@ -78,16 +77,16 @@ public void testCreateWithAntiAffinityPolicy() {
.waitUntilComplete()
.getResult();

assert !isNullOrEmpty(server.getId());
assert server != null;

ServerMetadata metadata = serverService.findByRef(Server.refById(server.getId()));
ServerMetadata metadata = serverService.findByRef(server);

assertEquals(metadata.getDetails().getAntiAffinityPolicy().getName(), "Policy CA3");
}

@AfterMethod
public void deleteServer() {
serverService.delete(server.asRefById());
serverService.delete(server);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import org.testng.annotations.Test;

import static com.centurylink.cloud.sdk.base.services.dsl.domain.datacenters.refs.DataCenter.CA_TORONTO_2;
import static com.centurylink.cloud.sdk.core.util.Strings.isNullOrEmpty;
import static com.centurylink.cloud.sdk.tests.TestGroups.RECORDED;

/**
Expand All @@ -50,7 +49,7 @@ public class CreateWithAutoscalePolicyTest extends AbstractServersSdkTest implem
@Inject
ServerService serverService;

ServerMetadata server;
Server server;

@Test
@WireMockFileSource("autoscale")
Expand Down Expand Up @@ -80,13 +79,13 @@ public void testCreateWithAutoscalePolicy() {
.waitUntilComplete()
.getResult();

assert !isNullOrEmpty(server.getId());
assert server != null;

ServerMetadata metadata = serverService.findByRef(Server.refById(server.getId()));
ServerMetadata metadata = serverService.findByRef(server);
assert metadata.getDetails().getAutoscalePolicy() != null;

AutoscalePolicyMetadata autoscalePolicy =
autoscalePolicyService.getAutoscalePolicyOnServer(server.asRefById());
autoscalePolicyService.getAutoscalePolicyOnServer(server);
assert autoscalePolicy != null;

assertEquals(metadata.getDetails().getAutoscalePolicy().getId(), autoscalePolicy.getId());
Expand All @@ -96,7 +95,7 @@ public void testCreateWithAutoscalePolicy() {

@AfterMethod
public void deleteServer() {
serverService.delete(server.asRefById());
serverService.delete(server);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.centurylink.cloud.sdk.server.services.client.domain.server.CustomField;
import com.centurylink.cloud.sdk.server.services.client.domain.server.metadata.ServerMetadata;
import com.centurylink.cloud.sdk.server.services.dsl.ServerService;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.refs.Server;
import com.centurylink.cloud.sdk.server.services.dsl.servers.TestServerSupport;
import com.centurylink.cloud.sdk.tests.recorded.WireMockFileSource;
import com.centurylink.cloud.sdk.tests.recorded.WireMockMixin;
Expand All @@ -29,7 +30,6 @@
import java.util.List;

import static com.centurylink.cloud.sdk.tests.TestGroups.RECORDED;
import static com.centurylink.cloud.sdk.core.util.Strings.isNullOrEmpty;

/**
* @author Aliaksandr Krasitski
Expand All @@ -40,7 +40,7 @@ public class CreateWithCustomFieldsTest extends AbstractServersSdkTest implement
@Inject
ServerService serverService;

ServerMetadata server;
Server server;

@Test
@WireMockFileSource("custom-fields")
Expand All @@ -59,11 +59,11 @@ public void testCreateServer() throws Exception {
.waitUntilComplete()
.getResult();

assert !isNullOrEmpty(server.getId());
assert server != null;

server = serverService.findByRef(server.asRefById());
ServerMetadata serverMetadata = serverService.findByRef(server);

List<CustomField> customFields = server.getDetails().getCustomFields();
List<CustomField> customFields = serverMetadata.getDetails().getCustomFields();
assert customFields.size() == 2;

customFields.forEach(field -> {
Expand All @@ -78,7 +78,7 @@ public void testCreateServer() throws Exception {

@AfterMethod
public void deleteServer() {
serverService.delete(server.asRefById().asFilter());
serverService.delete(server.asFilter());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,15 @@

import com.centurylink.cloud.sdk.core.injector.Inject;
import com.centurylink.cloud.sdk.server.services.AbstractServersSdkTest;
import com.centurylink.cloud.sdk.server.services.client.domain.server.metadata.ServerMetadata;
import com.centurylink.cloud.sdk.server.services.dsl.ServerService;
import com.centurylink.cloud.sdk.server.services.dsl.domain.group.refs.Group;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.refs.Server;
import com.centurylink.cloud.sdk.server.services.dsl.domain.template.filters.os.CpuArchitecture;
import com.centurylink.cloud.sdk.server.services.dsl.domain.template.filters.os.OsType;
import com.centurylink.cloud.sdk.server.services.dsl.domain.template.refs.Template;
import com.centurylink.cloud.sdk.server.services.dsl.servers.TestServerSupport;

import static com.centurylink.cloud.sdk.base.services.dsl.domain.datacenters.refs.DataCenter.US_EAST_STERLING;
import static com.centurylink.cloud.sdk.core.util.Strings.isNullOrEmpty;

/**
* @author Ilya Drabenia
Expand All @@ -37,7 +36,7 @@ public class CreateWithManagedOsTest extends AbstractServersSdkTest {
@Inject
ServerService serverService;

ServerMetadata server;
Server server;

// @Test
public void testCreateWithManagedOS() {
Expand All @@ -59,12 +58,12 @@ public void testCreateWithManagedOS() {
.waitUntilComplete()
.getResult();

assert !isNullOrEmpty(server.getId());
assert server != null;
}

// @AfterMethod
public void deleteServer() {
serverService.delete(server.asRefById());
serverService.delete(server);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@

import com.centurylink.cloud.sdk.core.injector.Inject;
import com.centurylink.cloud.sdk.server.services.AbstractServersSdkTest;
import com.centurylink.cloud.sdk.server.services.client.domain.server.metadata.ServerMetadata;
import com.centurylink.cloud.sdk.server.services.dsl.ServerService;
import com.centurylink.cloud.sdk.server.services.dsl.domain.ip.CreatePublicIpConfig;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.NetworkConfig;
import com.centurylink.cloud.sdk.server.services.dsl.domain.server.refs.Server;
import com.centurylink.cloud.sdk.server.services.dsl.servers.TestServerSupport;
import com.centurylink.cloud.sdk.tests.recorded.WireMockFileSource;
import com.centurylink.cloud.sdk.tests.recorded.WireMockMixin;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.Test;

import static com.centurylink.cloud.sdk.tests.TestGroups.RECORDED;
import static com.centurylink.cloud.sdk.core.util.Strings.isNullOrEmpty;

/**
* @author Ilya Drabenia
Expand All @@ -39,7 +38,7 @@ public class CreateWithPublicIpTest extends AbstractServersSdkTest implements Wi
@Inject
ServerService serverService;

ServerMetadata server;
Server server;

@Test
@WireMockFileSource("/ip")
Expand All @@ -56,12 +55,12 @@ public void testCreateServerWithPublicIp() throws Exception {
.waitUntilComplete()
.getResult();

assert !isNullOrEmpty(server.getId());
assert server != null;
}

@AfterMethod
public void deleteServer() {
serverService.delete(server.asRefById().asFilter());
serverService.delete(server.asFilter());
}

}
Loading