Search in sources :

Example 1 with Region

use of org.openstack4j.model.identity.v3.Region in project camel by apache.

the class RegionProducer method doUpdate.

private void doUpdate(Exchange exchange) {
    final Message msg = exchange.getIn();
    final Region in = messageToRegion(msg);
    final Region out = osV3Client.identity().regions().update(in);
    msg.setBody(out);
}
Also used : Message(org.apache.camel.Message) Region(org.openstack4j.model.identity.v3.Region)

Example 2 with Region

use of org.openstack4j.model.identity.v3.Region in project camel by apache.

the class RegionProducer method messageToRegion.

private Region messageToRegion(Message message) {
    Region region = message.getBody(Region.class);
    if (region == null) {
        Map headers = message.getHeaders();
        RegionBuilder builder = Builders.region();
        if (headers.containsKey(KeystoneConstants.DESCRIPTION)) {
            builder.description(message.getHeader(KeystoneConstants.DESCRIPTION, String.class));
        }
        region = builder.build();
    }
    return region;
}
Also used : Region(org.openstack4j.model.identity.v3.Region) RegionBuilder(org.openstack4j.model.identity.v3.builder.RegionBuilder) Map(java.util.Map)

Example 3 with Region

use of org.openstack4j.model.identity.v3.Region in project camel by apache.

the class RegionProducer method doGet.

private void doGet(Exchange exchange) {
    final String id = exchange.getIn().getHeader(OpenstackConstants.ID, String.class);
    ObjectHelper.notEmpty(id, "Region ID");
    final Region out = osV3Client.identity().regions().get(id);
    exchange.getIn().setBody(out);
}
Also used : Region(org.openstack4j.model.identity.v3.Region)

Example 4 with Region

use of org.openstack4j.model.identity.v3.Region in project openstack4j by ContainX.

the class KeystoneRegionServiceTest method region_crud_test.

// ------------ Region Tests ------------
// The following tests are to verify the update() method of the
// RegionService
// using HTTP PATCH, which is not supported by betamax.
// Find more tests in KeystoneRegionServiceSpec in core-integration-test
// module.
public void region_crud_test() throws Exception {
    respondWith(JSON_REGIONS_GET_BYID);
    Region region_setToUpdate = osv3().identity().regions().get(REGION_CRUD_ID);
    assertEquals(region_setToUpdate.getId(), REGION_CRUD_ID);
    assertEquals(region_setToUpdate.getDescription(), REGION_CRUD_DESCRIPTION);
    respondWith(JSON_REGIONS_UPDATE);
    Region updatedRegion = osv3().identity().regions().update(region_setToUpdate.toBuilder().description(REGION_CRUD_DESCRIPTION_UPDATE).build());
    assertEquals(updatedRegion.getId(), REGION_CRUD_ID);
    assertEquals(updatedRegion.getDescription(), REGION_CRUD_DESCRIPTION_UPDATE);
    assertEquals(updatedRegion.getParentRegionId(), REGION_CRUD_PARENTREGIONID);
}
Also used : Region(org.openstack4j.model.identity.v3.Region)

Example 5 with Region

use of org.openstack4j.model.identity.v3.Region in project camel by apache.

the class RegionProducer method doCreate.

private void doCreate(Exchange exchange) {
    final Region in = messageToRegion(exchange.getIn());
    final Region out = osV3Client.identity().regions().create(in);
    exchange.getIn().setBody(out);
}
Also used : Region(org.openstack4j.model.identity.v3.Region)

Aggregations

Region (org.openstack4j.model.identity.v3.Region)7 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Message (org.apache.camel.Message)1 RegionProducer (org.apache.camel.component.openstack.keystone.producer.RegionProducer)1 Before (org.junit.Before)1 Test (org.junit.Test)1 Matchers.anyString (org.mockito.Matchers.anyString)1 RegionBuilder (org.openstack4j.model.identity.v3.builder.RegionBuilder)1