Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Feature/pe 344 support listing qos policies (#4)
Browse files Browse the repository at this point in the history
* [PE-344] Add support for managing QoS policies

* [PE-344] Upgraded maven-compiler-plugin to resolve some compilation issues with JDK 1.8

* [PE-344] Add rule type property.
  • Loading branch information
jmaness authored Jan 8, 2019
1 parent 7a90335 commit 4475be5
Show file tree
Hide file tree
Showing 20 changed files with 1,045 additions and 6 deletions.
2 changes: 1 addition & 1 deletion connectors/http-connector/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
2 changes: 1 addition & 1 deletion connectors/jersey2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,4 +83,10 @@ public interface NetworkingService extends RestService {
* @return the Availability Zone Service API
*/
AvailabilityZoneService availabilityzone();

/**
*
* @return QoS Policy Service API
*/
QoSPolicyService qosPolicies();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package org.openstack4j.api.networking;

import org.openstack4j.common.RestService;
import org.openstack4j.model.common.ActionResponse;
import org.openstack4j.model.network.QoSPolicy;
import org.openstack4j.model.network.options.QoSPolicyListOptions;

import java.util.List;

public interface QoSPolicyService extends RestService {

/**
* Lists all QoS policies authorized by the current Tenant
*
* @return the list of QoS policies
*/
List<? extends QoSPolicy> list();

/**
* Lists all QoS policies authorized by the current Tenant
*
* @param options filtering options
* @return the list of QoS policies
*/
List<? extends QoSPolicy> list(QoSPolicyListOptions options);

/**
* Gets the QoS policy by ID
*
* @param policyId the QoS QoSPolicy identifier
* @return the QoSPolicy or null if not found
*/
QoSPolicy get(String policyId);

/**
* Delete a QoSPolicy by ID
*
* @param policyId the policy identifier to delete
* @return the action response
*/
ActionResponse delete(String policyId);

/**
* Creates a new QoSPolicy
* @param policy the QoSPolicy to create
* @return the newly create QoSPolicy
*/
QoSPolicy create(QoSPolicy policy);

/**
* Updates an existing QoSPolicy. The QoSPolicy identifier must be set on the policy object to be successful
* @param policy the QoSPolicy to update
* @return the updated QoSPolicy
*/
QoSPolicy update(QoSPolicy policy);
}
42 changes: 42 additions & 0 deletions core/src/main/java/org/openstack4j/model/network/QoSPolicy.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package org.openstack4j.model.network;

import org.openstack4j.common.Buildable;
import org.openstack4j.model.common.Resource;
import org.openstack4j.model.network.builder.BandwidthLimitRuleBuilder;
import org.openstack4j.model.network.builder.DscpMarkingRuleBuilder;
import org.openstack4j.model.network.builder.MinimumBandwidthRuleBuilder;
import org.openstack4j.model.network.builder.QoSPolicyBuilder;

import java.util.List;
import java.util.Set;

public interface QoSPolicy extends Resource, Buildable<QoSPolicyBuilder> {
String getDescription();
String getProjectId();
int getRevisionNumber();
boolean isShared();
List<? extends Rule> getRules();
boolean isDefault();
String getCreatedAt();
String getUpdatedAt();

interface Rule extends Resource {
String getType();
Set<String> getTags();
}

interface BandwidthLimitRule extends Rule, Buildable<BandwidthLimitRuleBuilder> {
Integer getMaxKbps();
Integer getMaxBurstKbps();
String getDirection();
}

interface DscpMarkingRule extends Rule, Buildable<DscpMarkingRuleBuilder> {
Integer getDscpMark();
}

interface MinimumBandwidthRule extends Rule, Buildable<MinimumBandwidthRuleBuilder> {
Integer getMinKbps();
String getDirection();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package org.openstack4j.model.network.builder;

import org.openstack4j.common.Buildable.Builder;
import org.openstack4j.model.network.QoSPolicy;

public interface BandwidthLimitRuleBuilder extends Builder<BandwidthLimitRuleBuilder, QoSPolicy.BandwidthLimitRule> {
BandwidthLimitRuleBuilder maxKbps(Integer maxKbps);
BandwidthLimitRuleBuilder maxBurstKbps(Integer maxBurstKbps);
BandwidthLimitRuleBuilder direction(String direction);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package org.openstack4j.model.network.builder;

import org.openstack4j.common.Buildable.Builder;
import org.openstack4j.model.network.QoSPolicy.DscpMarkingRule;

import java.util.Set;

public interface DscpMarkingRuleBuilder extends Builder<DscpMarkingRuleBuilder, DscpMarkingRule> {
DscpMarkingRuleBuilder dscpMark(Integer dscpMark);
DscpMarkingRuleBuilder id(String id);
DscpMarkingRuleBuilder tags(Set<String> tags);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.openstack4j.model.network.builder;

import org.openstack4j.common.Buildable.Builder;
import org.openstack4j.model.network.QoSPolicy.MinimumBandwidthRule;

import java.util.Set;

public interface MinimumBandwidthRuleBuilder extends Builder<MinimumBandwidthRuleBuilder, MinimumBandwidthRule> {
MinimumBandwidthRuleBuilder minKbps(Integer minKbps);
MinimumBandwidthRuleBuilder id(String id);
MinimumBandwidthRuleBuilder direction(String direction);
MinimumBandwidthRuleBuilder tags(Set<String> tags);
}
Original file line number Diff line number Diff line change
Expand Up @@ -252,4 +252,13 @@ public interface NetworkBuilders {
* @return HealthMonitorV2UpdateBuilder
*/
public HealthMonitorV2UpdateBuilder healthMonitorV2Update();

QoSPolicyBuilder qosPolicy();

BandwidthLimitRuleBuilder bandwidthLimitRule();

DscpMarkingRuleBuilder dscpMarkingRule();

MinimumBandwidthRuleBuilder minimumBandwidthRule();

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.openstack4j.model.network.builder;

import org.openstack4j.common.Buildable.Builder;
import org.openstack4j.model.network.QoSPolicy;
import org.openstack4j.model.network.QoSPolicy.Rule;

import java.util.List;

public interface QoSPolicyBuilder extends Builder<QoSPolicyBuilder, QoSPolicy> {
QoSPolicyBuilder description(String description);
QoSPolicyBuilder tenantId(String tenantId);
QoSPolicyBuilder projectId(String projectId);
QoSPolicyBuilder revisionNumber(int revisionNumber);
QoSPolicyBuilder shared(boolean shared);
QoSPolicyBuilder rules(List<? extends Rule> rules);
QoSPolicyBuilder id(String id);
QoSPolicyBuilder isDefault(boolean isDefault);
QoSPolicyBuilder name(String name);
QoSPolicyBuilder createdAt(String createdAt);
QoSPolicyBuilder updatedAt(String updatedAt);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
package org.openstack4j.model.network.options;

import com.google.common.collect.Maps;

import java.util.Map;
import java.util.Set;

public class QoSPolicyListOptions {

private Map<String, Object> queryParams = Maps.newHashMap();

private QoSPolicyListOptions() { }

public static QoSPolicyListOptions create() {
return new QoSPolicyListOptions();
}

/**
* The human-readable description of the resource
*
* @param description QoS policy description
* @return options
*/
public QoSPolicyListOptions description(String description) {
return add("description", description);
}

/**
* ID of the project that owns the resource
*
* @param tenantId ID of the project
* @return options
*/
public QoSPolicyListOptions tenantId(String tenantId) {
return add("tenant_id", tenantId);
}

/**
* ID of the project that owns the resource
*
* @param projectId ID of the project
* @return options
*/
public QoSPolicyListOptions projectId(String projectId) {
return add("project_id", projectId);
}

/**
* Revision number of the resource
*
* @param revisionNumber revision number
* @return options
*/
public QoSPolicyListOptions revisionNumber(Integer revisionNumber) {
return add("revision_number", revisionNumber);
}

/**
* Whether a policy is shared across all projects.
*
* @param shared whether this policy is shared across all projects.
* @return options
*/
public QoSPolicyListOptions shared(Boolean shared) {
return add("shared", shared);
}

/**
* ID of the resource
*
* @param id QoS policy ID
* @return options
*/
public QoSPolicyListOptions id(String id) {
return add("id", id);
}

/**
* Whether a policy is the default policy
*
* @param isDefault a policy is the default policy
* @return options
*/
public QoSPolicyListOptions isDefault(Boolean isDefault) {
return add("is_default", isDefault);
}

/**
* Name of a policy
*
* @param name policy name
* @return options
*/
public QoSPolicyListOptions name(String name) {
return add("name", name);
}

/**
* Set of tags that all must be associated to a policy
*
* @param tags set of tags
* @return options
*/
public QoSPolicyListOptions tags(Set<String> tags) {
return add("tags", String.join(",", tags));
}

/**
* Set of tags that only some must be associated to a policy
*
* @param tags set that only some must be associated to a policy
* @return options
*/
public QoSPolicyListOptions tagsAny(Set<String> tags) {
return add("tags-any", String.join(",", tags));
}

/**
* Set of tags that must not all be associated to a policy.
*
* @param tags set that must not all be associated to a policy
* @return options
*/
public QoSPolicyListOptions notTags(Set<String> tags) {
return add("not-tags", String.join(",", tags));
}

/**
* Set of tags where no subset should be associated to a policy
*
* @param tags no subset should be associated to a policy
* @return options
*/
public QoSPolicyListOptions notTagsAny(Set<String> tags) {
return add("not-tags-any", String.join(",", tags));
}

/**
* Sort direction:
* - asc (ascending)
* - desc (descending)
*
* @param direction sort direction
* @return options
*/
public QoSPolicyListOptions sortDir(String direction) {
return add("sort_dir", direction);
}

/**
* Name of field by which to to sort
*
* @param key sort key
* @return options
*/
public QoSPolicyListOptions sortKey(String key) {
return add("sort_key", key);
}

/**
* Set of field names to include in the list of QoS policies
*
* @param fields set of field names to include in the list of QoS policies
* @return options
*/
public QoSPolicyListOptions fields(Set<String> fields) {
return add("fields", fields);
}

private QoSPolicyListOptions add(String param, Object value) {
if (value != null)
this.queryParams.put(param, value);
return this;
}

public Map<String, Object> getOptions() {
return queryParams;
}
}
Loading

0 comments on commit 4475be5

Please sign in to comment.