You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jclouds.apache.org by ab...@apache.org on 2013/12/16 21:58:57 UTC
git commit: Fix CloudStack EgressFirewall request parameter name
Updated Branches:
refs/heads/master 5ba527ec3 -> 6d9784c4b
Fix CloudStack EgressFirewall request parameter name
createEgressFirewall needs networkid instead of ipaddressid:
http://download.cloud.com/releases/3.0.6/api_3.0.6/root_admin/createEgressFirewallRule.html
Project: http://git-wip-us.apache.org/repos/asf/jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/jclouds/commit/6d9784c4
Tree: http://git-wip-us.apache.org/repos/asf/jclouds/tree/6d9784c4
Diff: http://git-wip-us.apache.org/repos/asf/jclouds/diff/6d9784c4
Branch: refs/heads/master
Commit: 6d9784c4b5b771afde2b01168a2cc74102da877e
Parents: 5ba527e
Author: Hyeonu Jeong <hy...@gmail.com>
Authored: Thu Dec 12 15:28:08 2013 +0900
Committer: Andrew Bayer <an...@gmail.com>
Committed: Mon Dec 16 12:58:50 2013 -0800
----------------------------------------------------------------------
.../cloudstack/features/FirewallApi.java | 11 +-
.../options/ListEgressFirewallRulesOptions.java | 179 +++++++++++++++++++
.../features/FirewallApiExpectTest.java | 6 +-
.../features/FirewallApiLiveTest.java | 4 +-
4 files changed, 190 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6d9784c4/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallApi.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallApi.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallApi.java
index 386fc1b..29b8b33 100644
--- a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallApi.java
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/features/FirewallApi.java
@@ -32,6 +32,7 @@ import org.jclouds.cloudstack.domain.FirewallRule;
import org.jclouds.cloudstack.domain.PortForwardingRule;
import org.jclouds.cloudstack.filters.AuthenticationFilter;
import org.jclouds.cloudstack.options.CreateFirewallRuleOptions;
+import org.jclouds.cloudstack.options.ListEgressFirewallRulesOptions;
import org.jclouds.cloudstack.options.ListFirewallRulesOptions;
import org.jclouds.cloudstack.options.ListPortForwardingRulesOptions;
import org.jclouds.rest.annotations.Fallback;
@@ -118,7 +119,7 @@ public interface FirewallApi {
@SelectJson("firewallrule")
@Consumes(MediaType.APPLICATION_JSON)
@Fallback(EmptySetOnNotFoundOr404.class)
- Set<FirewallRule> listEgressFirewallRules(ListFirewallRulesOptions... options);
+ Set<FirewallRule> listEgressFirewallRules(ListEgressFirewallRulesOptions... options);
/**
* @see FirewallApi#getEgressFirewallRule
@@ -133,26 +134,26 @@ public interface FirewallApi {
FirewallRule getEgressFirewallRule(@QueryParam("id") String id);
/**
- * @see FirewallApi#createEgressFirewallRuleForIpAndProtocol
+ * @see FirewallApi#createEgressFirewallRuleForNetworkAndProtocol
*/
@Named("createEgressFirewallRule")
@GET
@QueryParams(keys = "command", values = "createEgressFirewallRule")
@Unwrap
@Consumes(MediaType.APPLICATION_JSON)
- AsyncCreateResponse createEgressFirewallRuleForIpAndProtocol(@QueryParam("ipaddressid") String ipAddressId,
+ AsyncCreateResponse createEgressFirewallRuleForNetworkAndProtocol(@QueryParam("networkid") String networkId,
@QueryParam("protocol") FirewallRule.Protocol protocol,
CreateFirewallRuleOptions... options);
/**
- * @see FirewallApi#createEgressFirewallRuleForIpProtocolAndPort
+ * @see FirewallApi#createEgressFirewallRuleForNetworkProtocolAndPort
*/
@Named("createEgressFirewallRule")
@GET
@QueryParams(keys = "command", values = "createEgressFirewallRule")
@Unwrap
@Consumes(MediaType.APPLICATION_JSON)
- AsyncCreateResponse createEgressFirewallRuleForIpProtocolAndPort(@QueryParam("ipaddressid") String ipAddressId,
+ AsyncCreateResponse createEgressFirewallRuleForNetworkProtocolAndPort(@QueryParam("networkId") String networkId,
@QueryParam("protocol") FirewallRule.Protocol protocol,
@QueryParam("startPort") int startPort,
@QueryParam("endPort") int endPort);
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6d9784c4/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEgressFirewallRulesOptions.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEgressFirewallRulesOptions.java b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEgressFirewallRulesOptions.java
new file mode 100644
index 0000000..0a9eacc
--- /dev/null
+++ b/apis/cloudstack/src/main/java/org/jclouds/cloudstack/options/ListEgressFirewallRulesOptions.java
@@ -0,0 +1,179 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jclouds.cloudstack.options;
+
+import com.google.common.collect.ImmutableSet;
+
+/**
+ * Options used to control what egress firewall rules are returned
+ *
+ * @see <a href=
+ * "http://download.cloud.com/releases/3.0.6/api_3.0.6/root_admin/listEgressFirewallRules.html"
+ * />
+ * @author Hyeonu Jeong
+ */
+public class ListEgressFirewallRulesOptions extends AccountInDomainOptions {
+
+ public static final ListEgressFirewallRulesOptions NONE = new ListEgressFirewallRulesOptions();
+
+ /**
+ * @param id
+ * firewall rule ID
+ */
+ public ListEgressFirewallRulesOptions id(String id) {
+ this.queryParameters.replaceValues("id", ImmutableSet.of(id + ""));
+ return this;
+ }
+
+ /**
+ * @param networkId
+ * the id of network of the firewall services
+ */
+ public ListEgressFirewallRulesOptions networkId(String networkId) {
+ this.queryParameters.replaceValues("networkid", ImmutableSet.of(networkId + ""));
+ return this;
+ }
+
+ /**
+ * @param ipAddressId
+ * the id of IP address of the firewall services
+ */
+ public ListEgressFirewallRulesOptions ipAddressId(String ipAddressId) {
+ this.queryParameters.replaceValues("ipaddressid", ImmutableSet.of(ipAddressId + ""));
+ return this;
+ }
+
+ /**
+ * @param projectId
+ * List firewall rules in this project.
+ */
+ public ListEgressFirewallRulesOptions projectId(String projectId) {
+ this.queryParameters.replaceValues("projectid", ImmutableSet.of(projectId + ""));
+ return this;
+ }
+
+ /**
+ * @param keyword
+ * list by keyword
+ */
+ public ListEgressFirewallRulesOptions keyword(String keyword) {
+ this.queryParameters.replaceValues("keyword", ImmutableSet.of(keyword));
+ return this;
+ }
+
+ public ListEgressFirewallRulesOptions page(long page) {
+ this.queryParameters.replaceValues("page", ImmutableSet.of(page + ""));
+ return this;
+ }
+
+ public ListEgressFirewallRulesOptions pageSize(long pageSize) {
+ this.queryParameters.replaceValues("pagesize", ImmutableSet.of(pageSize + ""));
+ return this;
+ }
+
+ public static class Builder {
+
+ /**
+ * @see ListEgressFirewallRulesOptions#id
+ */
+ public static ListEgressFirewallRulesOptions id(String id) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.id(id);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#networkId
+ */
+ public static ListEgressFirewallRulesOptions networkId(String networkId) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.networkId(networkId);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#ipAddressId
+ */
+ public static ListEgressFirewallRulesOptions ipAddressId(String ipAddressId) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.ipAddressId(ipAddressId);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#projectId(String)
+ */
+ public static ListEgressFirewallRulesOptions projectId(String projectId) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.projectId(projectId);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#keyword
+ */
+ public static ListEgressFirewallRulesOptions keyword(String keyword) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.keyword(keyword);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#page
+ */
+ public static ListEgressFirewallRulesOptions page(long page) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.page(page);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#pageSize
+ */
+ public static ListEgressFirewallRulesOptions pageSize(long pageSize) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.pageSize(pageSize);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#accountInDomain
+ */
+ public static ListEgressFirewallRulesOptions accountInDomain(String account, String domain) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.accountInDomain(account, domain);
+ }
+
+ /**
+ * @see ListEgressFirewallRulesOptions#domainId
+ */
+ public static ListEgressFirewallRulesOptions domainId(String id) {
+ ListEgressFirewallRulesOptions options = new ListEgressFirewallRulesOptions();
+ return options.domainId(id);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ListEgressFirewallRulesOptions accountInDomain(String account, String domain) {
+ return ListEgressFirewallRulesOptions.class.cast(super.accountInDomain(account, domain));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ListEgressFirewallRulesOptions domainId(String domainId) {
+ return ListEgressFirewallRulesOptions.class.cast(super.domainId(domainId));
+ }
+}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6d9784c4/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
index 61e1c51..0de4c61 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiExpectTest.java
@@ -363,13 +363,13 @@ public class FirewallApiExpectTest extends BaseCloudStackExpectTest<FirewallApi>
assertNull(client.getEgressFirewallRule("4"));
}
- public void testCreateEgressFirewallRuleForIpAndProtocol() {
+ public void testCreateEgressFirewallRuleForNetworkAndProtocol() {
FirewallApi client = requestSendsResponse(
HttpRequest.builder()
.method("GET")
.endpoint(
URI.create("http://localhost:8080/client/api?response=json&command=createEgressFirewallRule&" +
- "ipaddressid=2&protocol=TCP&apiKey=identity&signature=%2BlfEJ5zB7lxqRAn0rY0Rcfg9buw%3D"))
+ "networkid=2&protocol=TCP&apiKey=identity&signature=I/OJEqiLp8ZHlZskKUiT5uTRE3M%3D"))
.addHeader("Accept", "application/json")
.build(),
HttpResponse.builder()
@@ -377,7 +377,7 @@ public class FirewallApiExpectTest extends BaseCloudStackExpectTest<FirewallApi>
.payload(payloadFromResource("/createegressfirewallrulesresponse.json"))
.build());
- AsyncCreateResponse response = client.createEgressFirewallRuleForIpAndProtocol("2", FirewallRule.Protocol.TCP);
+ AsyncCreateResponse response = client.createEgressFirewallRuleForNetworkAndProtocol("2", FirewallRule.Protocol.TCP);
assertEquals(response.getJobId(), "2036");
assertEquals(response.getId(), "2017");
}
http://git-wip-us.apache.org/repos/asf/jclouds/blob/6d9784c4/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
----------------------------------------------------------------------
diff --git a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
index 981b03e..eaa0499 100644
--- a/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
+++ b/apis/cloudstack/src/test/java/org/jclouds/cloudstack/features/FirewallApiLiveTest.java
@@ -157,8 +157,8 @@ public class FirewallApiLiveTest extends BaseCloudStackApiLiveTest {
if (networksDisabled)
return;
- AsyncCreateResponse job = client.getFirewallApi().createEgressFirewallRuleForIpAndProtocol(
- ip.getId(), FirewallRule.Protocol.TCP, CreateFirewallRuleOptions.Builder.startPort(30).endPort(35));
+ AsyncCreateResponse job = client.getFirewallApi().createEgressFirewallRuleForNetworkAndProtocol(
+ network.getId(), FirewallRule.Protocol.TCP, CreateFirewallRuleOptions.Builder.startPort(30).endPort(35));
assertTrue(jobComplete.apply(job.getJobId()));
egressFirewallRule = client.getFirewallApi().getEgressFirewallRule(job.getId());