Adding first gasp at SecurityGroupExtension

Project: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/commit/f969fb7d
Tree: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/tree/f969fb7d
Diff: http://git-wip-us.apache.org/repos/asf/incubator-jclouds/diff/f969fb7d

Branch: refs/heads/jclouds-101
Commit: f969fb7d3a0cac844e7113ebecda08f7be84567f
Parents: 9383591
Author: Andrew Bayer <[email protected]>
Authored: Fri Jun 7 15:35:59 2013 -0700
Committer: Andrew Bayer <[email protected]>
Committed: Fri Jun 7 15:35:59 2013 -0700

----------------------------------------------------------------------
 .../compute/domain/SecurityGroupRule.java       |  2 +-
 .../extensions/SecurityGroupExtension.java      | 81 ++++++++++++++++++++
 2 files changed, 82 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/f969fb7d/compute/src/main/java/org/jclouds/compute/domain/SecurityGroupRule.java
----------------------------------------------------------------------
diff --git 
a/compute/src/main/java/org/jclouds/compute/domain/SecurityGroupRule.java 
b/compute/src/main/java/org/jclouds/compute/domain/SecurityGroupRule.java
index 2e1c968..1dfe945 100644
--- a/compute/src/main/java/org/jclouds/compute/domain/SecurityGroupRule.java
+++ b/compute/src/main/java/org/jclouds/compute/domain/SecurityGroupRule.java
@@ -96,7 +96,7 @@ public class SecurityGroupRule {
 
    /**
     * 
-    * @return The set of instance group IDs for this rule.
+    * @return The set of @{link SecurityGroup} ids for this rule.
     */
    public Set<String> getGroupIds() {
       return groupIds;

http://git-wip-us.apache.org/repos/asf/incubator-jclouds/blob/f969fb7d/compute/src/main/java/org/jclouds/compute/extensions/SecurityGroupExtension.java
----------------------------------------------------------------------
diff --git 
a/compute/src/main/java/org/jclouds/compute/extensions/SecurityGroupExtension.java
 
b/compute/src/main/java/org/jclouds/compute/extensions/SecurityGroupExtension.java
new file mode 100644
index 0000000..9c00aaf
--- /dev/null
+++ 
b/compute/src/main/java/org/jclouds/compute/extensions/SecurityGroupExtension.java
@@ -0,0 +1,81 @@
+/*
+ * 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.compute.extensions;
+
+import org.jclouds.compute.domain.IpProtocol;
+import org.jclouds.compute.domain.SecurityGroup;
+import org.jclouds.compute.domain.SecurityGroupRule;
+import org.jclouds.domain.Location;
+
+import com.google.common.util.concurrent.ListenableFuture;
+
+/**
+ * An extension to compute service to allow for the manipulation of {@link 
SecurityGroup}s. Implementation
+ * is optional by providers.
+ * 
+ * @author Andrew Bayer
+ */
+public interface SecurityGroupExtension {
+
+   /**
+    * Create a new @{link SecurityGroup} from the parameters given.
+    *
+    * @param name
+    *           The name of the security group
+    * @param location
+    *           The @{link Location} of the security group
+    *
+    * @return The SecurityGroup that has been created.
+    */
+   SecurityGroup createSecurityGroup(String name, Location location);
+
+   /**
+    * Add a @{link SecurityGroupRule} to an existing @{link SecurityGroup}. 
Applies the rule to the
+    *   security group on the provider.
+    *
+    * @param rule
+    *           The SecurityGroupRule to add.
+    * @param group
+    *           The SecurityGroup to add the rule to.
+    *
+    * @return The SecurityGroup with the new rule added, after the rule has 
been applied on the provider.
+    */
+   SecurityGroup addRule(SecurityGroupRule rule, SecurityGroup group);
+
+   /**
+    * Add a @{link SecurityGroupRule} to an existing @{link SecurityGroup}, 
based on the parameters given.
+    *   Applies the rule to the security group on the provider.
+    *
+    * @param protocol
+    *           The @{link IpProtocol} for the rule.
+    * @param startPort
+    *           The first port in the range to be opened, or -1 for ICMP.
+    * @param endPort
+    *           The last port in the range to be opened, or -1 for ICMP.
+    * @param ipRanges
+    *           An Iterable of Strings representing the IP range(s) the rule 
should allow.
+    * @param groupIds
+    *           An Iterable of @{link SecurityGroup} IDs this rule should 
allow.
+    * @param group
+    *           The SecurityGroup to add the rule to.
+    *
+    * @return The SecurityGroup with the new rule added, after the rule has 
been applied on the provider.
+    */
+   SecurityGroup addRule(IpProtocol protocol, int startPort, int endPort, 
Iterable<String> ipRanges,
+                         Iterable<String> groupIds, SecurityGroup group);
+   
+}

Reply via email to