org.jclouds.googlecomputeengine.options.FirewallOptions Maven / Gradle / Ivy
/*
* 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.googlecomputeengine.options;
import java.net.URI;
import java.util.Set;
import org.jclouds.googlecomputeengine.domain.Firewall;
import com.google.common.collect.ImmutableSet;
/**
* Options to create a firewall.
*
* @author David Alves
* @see Firewall
*/
public class FirewallOptions {
private String name;
private URI network;
private ImmutableSet.Builder sourceRanges = ImmutableSet.builder();
private ImmutableSet.Builder sourceTags = ImmutableSet.builder();
private ImmutableSet.Builder targetTags = ImmutableSet.builder();
private ImmutableSet.Builder allowed = ImmutableSet.builder();
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed()
*/
public Set getAllowed() {
return allowed.build();
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed()
*/
public FirewallOptions addAllowedRule(Firewall.Rule allowedRule) {
this.allowed.add(allowedRule);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getAllowed()
*/
public FirewallOptions allowedRules(Set allowedRules) {
this.allowed = ImmutableSet.builder();
this.allowed.addAll(allowedRules);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getName()
*/
public FirewallOptions name(String name) {
this.name = name;
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getName()
*/
public String getName() {
return name;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getNetwork()
*/
public FirewallOptions network(URI network) {
this.network = network;
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getNetwork()
*/
public URI getNetwork() {
return network;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges()
*/
public Set getSourceRanges() {
return sourceRanges.build();
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges()
*/
public FirewallOptions addSourceRange(String sourceRange) {
this.sourceRanges.add(sourceRange);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceRanges()
*/
public FirewallOptions sourceRanges(Set sourceRanges) {
this.sourceRanges = ImmutableSet.builder();
this.sourceRanges.addAll(sourceRanges);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags()
*/
public Set getSourceTags() {
return sourceTags.build();
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags()
*/
public FirewallOptions addSourceTag(String sourceTag) {
this.sourceTags.add(sourceTag);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getSourceTags()
*/
public FirewallOptions sourceTags(Set sourceTags) {
this.sourceTags = ImmutableSet.builder();
this.sourceTags.addAll(sourceTags);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags()
*/
public Set getTargetTags() {
return targetTags.build();
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags()
*/
public FirewallOptions addTargetTag(String targetTag) {
this.targetTags.add(targetTag);
return this;
}
/**
* @see org.jclouds.googlecomputeengine.domain.Firewall#getTargetTags()
*/
public FirewallOptions targetTags(Set targetTags) {
this.targetTags = ImmutableSet.builder();
this.targetTags.addAll(targetTags);
return this;
}
}