This repository has been archived by the owner on Aug 3, 2022. It is now read-only.
forked from ContainX/openstack4j
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/pe 344 support listing qos policies (#4)
* [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
Showing
20 changed files
with
1,045 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
core/src/main/java/org/openstack4j/api/networking/QoSPolicyService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
42
core/src/main/java/org/openstack4j/model/network/QoSPolicy.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
core/src/main/java/org/openstack4j/model/network/builder/BandwidthLimitRuleBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
12 changes: 12 additions & 0 deletions
12
core/src/main/java/org/openstack4j/model/network/builder/DscpMarkingRuleBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
13 changes: 13 additions & 0 deletions
13
core/src/main/java/org/openstack4j/model/network/builder/MinimumBandwidthRuleBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
core/src/main/java/org/openstack4j/model/network/builder/QoSPolicyBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
179 changes: 179 additions & 0 deletions
179
core/src/main/java/org/openstack4j/model/network/options/QoSPolicyListOptions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.