Search in sources :

Example 1 with ServiceInstance

use of org.cloudfoundry.client.v2.serviceinstances.ServiceInstance in project cf-java-client by cloudfoundry.

the class DefaultServices method toServiceInstance.

private static ServiceInstance toServiceInstance(UnionServiceInstanceResource resource, Optional<String> plan, List<String> applications, ServiceEntity serviceEntity) {
    String extra = Optional.ofNullable(serviceEntity.getExtra()).orElse("");
    Optional<String> documentationUrl = Optional.ofNullable(getExtraValue(extra, "documentationUrl"));
    UnionServiceInstanceEntity serviceInstanceEntity = resource.getEntity();
    LastOperation lastOperation = Optional.ofNullable(serviceInstanceEntity.getLastOperation()).orElse(LastOperation.builder().build());
    return ServiceInstance.builder().applications(applications).dashboardUrl(serviceInstanceEntity.getDashboardUrl()).description(serviceEntity.getDescription()).documentationUrl(documentationUrl.orElse(null)).id(ResourceUtils.getId(resource)).lastOperation(lastOperation.getType()).message(lastOperation.getDescription()).name(serviceInstanceEntity.getName()).plan(plan.orElse(null)).service(serviceEntity.getLabel()).startedAt(lastOperation.getCreatedAt()).status(lastOperation.getState()).tags(serviceInstanceEntity.getTags()).type(ServiceInstanceType.from(serviceInstanceEntity.getType())).updatedAt(lastOperation.getUpdatedAt()).build();
}
Also used : UnionServiceInstanceEntity(org.cloudfoundry.client.v2.serviceinstances.UnionServiceInstanceEntity) LastOperation(org.cloudfoundry.client.v2.serviceinstances.LastOperation)

Example 2 with ServiceInstance

use of org.cloudfoundry.client.v2.serviceinstances.ServiceInstance in project cf-java-client by cloudfoundry.

the class ReactorServicePlansTest method get.

@Test
public void get() {
    Map<String, String> details = new HashMap<>();
    details.put("description", "Billing account number used to charge use of shared fake server.");
    details.put("type", "string");
    Schema testSchema = Schema.builder().parameters(Parameters.builder().jsonSchema("http://json-schema.org/draft-04/schema#").properties(Collections.singletonMap("billing-account", details)).type("object").build()).build();
    mockRequest(InteractionContext.builder().request(TestRequest.builder().method(GET).path("/service_plans/test-service-plan-id").build()).response(TestResponse.builder().status(OK).payload("fixtures/client/v2/service_plans/GET_{id}_response.json").build()).build());
    this.servicePlans.get(GetServicePlanRequest.builder().servicePlanId("test-service-plan-id").build()).as(StepVerifier::create).expectNext(GetServicePlanResponse.builder().metadata(Metadata.builder().createdAt("2015-07-27T22:43:16Z").id("f6ceb8a2-e6fc-43d5-a11b-7ced9e1b47c7").url("/v2/service_plans/f6ceb8a2-e6fc-43d5-a11b-7ced9e1b47c7").build()).entity(ServicePlanEntity.builder().name("name-462").free(false).description("desc-52").serviceId("8ac39757-0f9d-4295-9b6f-e626f7ee3cd4").uniqueId("2aa0162c-9c88-4084-ad1d-566a09e8d316").publiclyVisible(true).active(true).schemas(Schemas.builder().serviceBinding(ServiceBindingSchema.builder().create(testSchema).build()).serviceInstance(ServiceInstanceSchema.builder().create(testSchema).update(testSchema).build()).build()).serviceUrl("/v2/services/8ac39757-0f9d-4295-9b6f-e626f7ee3cd4").serviceInstancesUrl("/v2/service_plans/f6ceb8a2-e6fc-43d5-a11b-7ced9e1b47c7/service_instances").build()).build()).expectComplete().verify(Duration.ofSeconds(5));
}
Also used : HashMap(java.util.HashMap) ServiceBindingSchema(org.cloudfoundry.client.v2.serviceplans.ServiceBindingSchema) Schema(org.cloudfoundry.client.v2.serviceplans.Schema) ServiceInstanceSchema(org.cloudfoundry.client.v2.serviceplans.ServiceInstanceSchema) AbstractClientApiTest(org.cloudfoundry.reactor.client.AbstractClientApiTest) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)1 LastOperation (org.cloudfoundry.client.v2.serviceinstances.LastOperation)1 UnionServiceInstanceEntity (org.cloudfoundry.client.v2.serviceinstances.UnionServiceInstanceEntity)1 Schema (org.cloudfoundry.client.v2.serviceplans.Schema)1 ServiceBindingSchema (org.cloudfoundry.client.v2.serviceplans.ServiceBindingSchema)1 ServiceInstanceSchema (org.cloudfoundry.client.v2.serviceplans.ServiceInstanceSchema)1 AbstractClientApiTest (org.cloudfoundry.reactor.client.AbstractClientApiTest)1 Test (org.junit.Test)1