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

com.github.narcissujsk.openstackjsk.openstack.compute.domain.NovaRateLimit Maven / Gradle / Ivy

The newest version!
package com.github.narcissujsk.openstackjsk.openstack.compute.domain;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

import com.github.narcissujsk.openstackjsk.model.compute.RateLimit;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.common.base.MoreObjects;

/**
 * Rate limits are specified in terms of both a human-readable wild-card URI and a machine-processable regular expression.
 * The human-readable limit is intended for displaying in graphical user interfaces. The machine-processable form is
 * intended to be used directly by client applications.
 *
 * @author Jeremy Unruh
 */
public class NovaRateLimit implements RateLimit {

	private static final long serialVersionUID = 1L;

	private String regex;
	private String uri;
	private List limit;

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getRegex() {
		return regex;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getUri() {
		return uri;
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String toString() {
		return MoreObjects.toStringHelper(this).omitNullValues()
				    .add("limit", limit).add("regex", regex).add("uri", uri)
				    .toString();
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public List getLimit() {
		return limit;
	}

	public static class NovaLimitEntry implements LimitEntry, Serializable {

		private static final long serialVersionUID = 1L;

		@JsonProperty("next-available")
		private Date nextAvailable;
		private String unit;
		private String verb;
		private int remaining;
		private int available;
		private int value;

		/**
		 * {@inheritDoc}
		 */
		@Override
		public Date getNextAvailable() {
			return nextAvailable;
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		public String getUnit() {
			return unit;
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		public String getVerb() {
			return verb;
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		public int getRemaining() {
			return remaining;
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		public int getAvailable() {
			return available;
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		public int getValue() {
			return value;
		}

		/**
		 * {@inheritDoc}
		 */
		@Override
		public String toString() {
			return MoreObjects.toStringHelper(this).omitNullValues()
					    .add("next-available", nextAvailable).add("remaining", remaining).add("unit", unit)
					    .add("value", value).add("available", available).add("verb", verb)
					    .toString();
		}

	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy