protected AddressSpace createAddressSpace(String instanceId, String name, String type, String plan, String userId, String userName) throws Exception {
AuthenticationService authService = new AuthenticationServiceBuilder()
.withType(AuthenticationServiceType.STANDARD)
.withDetails(Collections.emptyMap())
.build();
AddressSpace addressSpace = new AddressSpaceBuilder()
.withNewMetadata()
.withName(name)
.addToAnnotations(AnnotationKeys.CREATED_BY, userName)
.addToAnnotations(AnnotationKeys.CREATED_BY_UID, userId)
.addToLabels(LabelKeys.SERVICE_INSTANCE_ID, instanceId)
.endMetadata()
.withNewSpec()
.withType(type)
.withPlan(plan)
.withAuthenticationService(authService)
.endSpec()
.build();
addressSpace = setDefaults(addressSpace, namespace);
addressSpaceApi.createAddressSpace(addressSpace);
log.info("Created MaaS addressspace {}", addressSpace.getMetadata().getName());
return addressSpace;
}