All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.woorea.openstack.nova.api.extensions.FloatingIpsExtension Maven / Gradle / Ivy

The newest version!
/*******************************************************************************
 * Copyright (C) 2016 AT&T Intellectual Property. All rights reserved. This code is licensed under the Apache License, Version 2.0
 *******************************************************************************/

package com.woorea.openstack.nova.api.extensions;

import java.util.HashMap;
import java.util.Map;


import com.woorea.openstack.base.client.Entity;
import com.woorea.openstack.base.client.HttpMethod;
import com.woorea.openstack.base.client.OpenStackClient;
import com.woorea.openstack.base.client.OpenStackRequest;
import com.woorea.openstack.nova.model.FloatingIp;
import com.woorea.openstack.nova.model.FloatingIps;

public class FloatingIpsExtension {
	
	private final OpenStackClient CLIENT;
	
	public FloatingIpsExtension(OpenStackClient client) {
		CLIENT = client;
	}
	
	public class List extends OpenStackRequest {

		public List() {
			super(CLIENT, HttpMethod.GET, "/os-floating-ips", null, FloatingIps.class);
		}

	}

	public class Allocate extends OpenStackRequest {
		
		public Allocate(Entity entity) {
			super(CLIENT, HttpMethod.POST, "/os-floating-ips", entity, FloatingIp.class);
		}

	}
	
	public class Deallocate extends OpenStackRequest {
		
		public Deallocate(String id) {
			super(CLIENT, HttpMethod.DELETE, new StringBuffer("/os-floating-ips/").append(id).toString(), null, Void.class);
		}
		
	}

	public List list() {
		return new List();
	}
	
	public Allocate allocate(String pool) {
		Entity entity=null;
		if(pool!=null) {
			Map body = new HashMap();
			body.put("pool", pool);
			entity=Entity.json(body);
		}
		return new Allocate(entity);
	}
	
	public Deallocate deallocate(String id) {
		return new Deallocate(id);
	}
	
	
	
}





© 2015 - 2024 Weber Informatics LLC | Privacy Policy