Search in sources :

Example 1 with SecurityGroupResponse

use of com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse in project cloudbreak by hortonworks.

the class SecurityGroupToSecurityGroupResponseConverterTest method testConvert.

@Test
public void testConvert() {
    // GIVEN
    given(conversionService.convert(any(Object.class), any(TypeDescriptor.class), any(TypeDescriptor.class))).willReturn(new ArrayList<SecurityRuleRequest>());
    // WHEN
    SecurityGroupResponse result = underTest.convert(getSource());
    // THEN
    assertAllFieldsNotNull(result, Arrays.asList("owner", "account"));
}
Also used : TypeDescriptor(org.springframework.core.convert.TypeDescriptor) SecurityGroupResponse(com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse) SecurityRuleRequest(com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest) Test(org.junit.Test)

Example 2 with SecurityGroupResponse

use of com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse in project cloudbreak by hortonworks.

the class CleanupService method deleteSecurityGroup.

public void deleteSecurityGroup(CloudbreakClient cloudbreakClient, String securityGroupId) {
    if (securityGroupId != null) {
        SecurityGroupEndpoint securityGroupEndpoint = cloudbreakClient.securityGroupEndpoint();
        SecurityGroupResponse securityGroupResponse = securityGroupEndpoint.get(Long.valueOf(securityGroupId));
        if (!itProps.isDefaultSecurityGroup(securityGroupResponse.getName())) {
            securityGroupEndpoint.delete(Long.valueOf(securityGroupId));
        }
    }
}
Also used : SecurityGroupResponse(com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse) SecurityGroupEndpoint(com.sequenceiq.cloudbreak.api.endpoint.v1.SecurityGroupEndpoint)

Example 3 with SecurityGroupResponse

use of com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse in project cloudbreak by hortonworks.

the class SecurityGroupToSecurityGroupResponseConverter method convert.

@Override
public SecurityGroupResponse convert(SecurityGroup source) {
    SecurityGroupResponse json = new SecurityGroupResponse();
    json.setId(source.getId());
    json.setName(source.getName());
    json.setDescription(source.getDescription());
    json.setAccount(source.getAccount());
    json.setOwner(source.getOwner());
    json.setPublicInAccount(source.isPublicInAccount());
    json.setSecurityRules(convertSecurityRules(source.getSecurityRules()));
    json.setSecurityGroupId(source.getSecurityGroupId());
    json.setCloudPlatform(source.getCloudPlatform());
    return json;
}
Also used : SecurityGroupResponse(com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse)

Aggregations

SecurityGroupResponse (com.sequenceiq.cloudbreak.api.model.SecurityGroupResponse)3 SecurityGroupEndpoint (com.sequenceiq.cloudbreak.api.endpoint.v1.SecurityGroupEndpoint)1 SecurityRuleRequest (com.sequenceiq.cloudbreak.api.model.SecurityRuleRequest)1 Test (org.junit.Test)1 TypeDescriptor (org.springframework.core.convert.TypeDescriptor)1