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

org.openstack4j.openstack.compute.internal.KeypairServiceImpl Maven / Gradle / Ivy

There is a newer version: 3.2.0
Show newest version
package org.openstack4j.openstack.compute.internal;

import static com.google.common.base.Preconditions.checkNotNull;

import java.util.List;

import javax.annotation.Nullable;

import org.openstack4j.api.compute.KeypairService;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.compute.Keypair;
import org.openstack4j.openstack.compute.domain.NovaKeypair;
import org.openstack4j.openstack.compute.domain.NovaKeypair.Keypairs;

/**
 * Keypair Service manages SSH Keys within OpenStack Compute (Nova).
 *
 * @author Jeremy Unruh
 */
public class KeypairServiceImpl extends BaseComputeServices implements KeypairService {

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List list() {
		return get(Keypairs.class, uri("/os-keypairs")).execute().getList();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Keypair get(String name) {
		checkNotNull(name);
		return get(NovaKeypair.class, uri("/os-keypairs/%s", name)).execute();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public ActionResponse delete(String name) {
		checkNotNull(name);
		return deleteWithResponse(uri("/os-keypairs/%s", name)).execute();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public Keypair create(String name, @Nullable String publicKey) {
		checkNotNull(name);
		return post(NovaKeypair.class, uri("/os-keypairs")).entity(NovaKeypair.create(name, publicKey)).execute();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy